Farly::Object::List - Searchable container of Farly::Objects


  use Farly::Object::List;
  use Farly::Object;
  use Farly::Value::String;
  my $object_1 = Farly::Object->new();
  $object_1->set( "id",        Farly::Value::String->new("id1234") );
  $object_1->set( "last_name", Farly::Value::String->new("Hofstadter") );
  my $object_n = Farly::Object->new();    

  $object_n->set( "id", Farly::Value::String->new("id9999") );

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

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

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

  my $search_result = Farly::Object::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";


Farly::Object::List is a searchable 'ARRAY' based container of Farly::Objects.



The constructor.

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

No arguments.

add( <Farly::Object> )

Add a new Farly::Object object to the container.

  $container->add( $object ); 


Return a new Farly::Object::List of cloned Farly::Object objects

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

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


Returns 'ARRAY' of the Farly::Object container elements.

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

includes( $object<Farly::Object> )

Returns true if an object in this List 'matches' the other object.

  $set1->includes( $object );

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

Store all objects which match $search in $result.

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

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

Store all objects which contain $search in $result.

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

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

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

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

search( $search<Farly::Object>, $result<Farly::Object::List> )

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

Applies matches, contains, contained_by, and intersects methods in that order.

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


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

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


Farly::Object::List Copyright (C) 2013 Trystan Johnson

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.