NAME

Farly::Object::Set - Set calculations on Farly::Objects

SYNOPSIS

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

  my $set1 = Farly::Object::Set->new();
  my $set2 = Farly::Object::Set->new();

  $set1->add( $object_1 );
  $set2->add( $object_n );

  my $intersection = $set1->intersection($set2);

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

DESCRIPTION

List based Set calculations on an arrays of Farly::Objects.

METHODS

new()

The constructor.

  my $set = Farly::Object::Set->new();

No arguments.

add( <object> )

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

  $set->add( $object ); 

iter()

Returns 'ARRAY' of the Set members.

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

size()

Returns integer value of the Set cardinality.

  my $set_size = $set1->size();

equals( $set<Farly::Object::Set> )

Returns true if both sets are the same size and every object in this Set has an equal object in the other Set.

  $set1->equals($set2);

contains( $set<Farly::Object::Set> or $object<Farly::Object> )

Returns true if objects in this Set 'contains' every object in the other Set.

  $set1->contains( $set2 );

Returns true if an object in this Set 'contains' the other object.

  $set1->contains( $object );

includes( $set<Farly::Object::Set> or $other<Farly::Object> )

Returns true if objects in this Set 'matches' every object in the other Set.

  $set1->includes( $set2 );

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

  $set1->includes( $object );

difference( $set<Farly::Object::Set> )

Returns a Set with the relative complement, which is the set of objects in self, but not in other.

  $set1->difference( $set2 );

disjoint( $set<Farly::Object::Set> )

Returns true if the Sets are disjoint.

  $set1->disjoint( $set2 );

intersects( $set<Farly::Object::Set> )

Returns true if the Sets intersect.

  $set1->intersects( $set2 );

intersection( $set<Farly::Object::Set> )

Returns a Set containing the objects which exist in both Sets.

  $intersection = $set1->intersection( $set2 );

union( $set<Farly::Object::Set> )

Returns a Set containing all the objects which exist in both Sets.

  $union = $set1->union( $set2 );

COPYRIGHT AND LICENCE

Farly::Object::Set Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.