Farly::Object::Set - Set calculations on Farly::Objects
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"; }
List based Set calculations on an arrays of Farly::Objects.
The constructor.
my $set = Farly::Object::Set->new();
No arguments.
Add a new Farly::Object object to the Set.
$set->add( $object );
Returns 'ARRAY' of the Set members.
my @objects = $set->iter();
Returns integer value of the Set cardinality.
my $set_size = $set1->size();
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);
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 );
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 );
Returns a Set with the relative complement, which is the set of objects in self, but not in other.
$set1->difference( $set2 );
Returns true if the Sets are disjoint.
$set1->disjoint( $set2 );
Returns true if the Sets intersect.
$set1->intersects( $set2 );
Returns a Set containing the objects which exist in both Sets.
$intersection = $set1->intersection( $set2 );
Returns a Set containing all the objects which exist in both Sets.
$union = $set1->union( $set2 );
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/>.
To install Farly, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Farly
CPAN shell
perl -MCPAN -e shell install Farly
For more information on module installation, please visit the detailed CPAN module installation guide.