NAME

Object::KVC::List - Searchable container of Object::KVC::Hash objects

SYNOPSIS

use Object::KVC::List;
use Object::KVC::Hash;
use Object::KVC::String;

my $object_1 = Object::KVC::Hash->new();
$object_1->set( "id",        Object::KVC::String->new("id1234") );
$object_1->set( "last_name", Object::KVC::String->new("Hofstadter") );
my $object_n = Object::KVC::Hash->new();    

$object_n->set( "id", Object::KVC::String->new("id9999") );

my $container = Object::KVC::List->new();

$container->add( $object_1 );
$container->add( $object_n );

my $search = Object::KVC::Hash->new();
$search->set( "id", Object::KVC::String->new("id1234") );

my $search_result = Object::KVC::List->new();

$container->matches( $search, $search_result );

foreach my $object ( $search_result->iter() ) {
    print $object->get("last_name")->as_string() if ( $object->has_defined("last_name") );
    print "\n";
}

DESCRIPTION

Object::KVC::List is a searchable 'ARRAY' based container of Object::KVC::Hash objects.

METHODS

new()

The constructor.

my $container = Object::KVC::List->new();

No arguments.

add( <Object::KVC::Hash> )

Add a new Object::KVC::Hash object to the container.

$container->add( $object ); 

clone()

Return a new Object::KVC::List of cloned Object::KVC::Hash objects

my $new_container = $container->clone(); 

Object::KVC::Hash->clone() does not clone the value objects in the Object::KVC::Hash container elements.

iter()

Returns 'ARRAY' of the Object::KVC::Hash container elements.

my @objects = $container->iter();

matches( $search<Object::KVC::Hash>, $result<Object::KVC::List> )

Stores all objects which match $search in $result.

$container->matches( $search, $result );

contains( $search<Object::KVC::Hash>, $result<Object::KVC::List> )

Stores all objects which contain $search in $result.

$container->contains( $search, $result );

contained_by( $search<Object::KVC::Hash>, $result<Object::KVC::List> )

Stores all objects which are contained by $search in $result.

$container->contained_by( $search, $result );

search( $search<Object::KVC::Hash>, $result<Object::KVC::List> )

Stores all objects which match, contain or are contained by $search in $result.

Applies matches, contains, and contained_by in order.

$container->search( $search, $result );

size()

Returns a count of the number of objects currently in the container.

my $size = $container->size();

COPYRIGHT AND LICENSE

Object::KVC::List Copyright (C) 2012 Trystan Johnson

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.