Usage - $set->add() Returns - true if the element was successfully added Args - the element to be added Function - adds an element to this set
Usage - $set->add_all($ele1, $ele2, $ele3, ...) Returns - true if the elements were successfully added Args - the elements to be added Function - adds the given elements to this set
Usage - $set->get_set() Returns - this set Args - none Function - returns this set
Usage - $set->contains($element) Returns - 1 (true) if this set contains the given element Args - the element to be checked Function - checks if this set constains the given element
Usage - $set->size() Returns - the size of this set Args - none Function - tells the number of elements held by this set
Usage - $set->clear() Returns - none Args - none Function - clears this list
Usage - $set->remove($element_to_be_removed) Returns - 1 (true) if this set contained the given element Args - element to be removed from this set, if present Function - removes an element from this set if it is present
Usage - $set->is_empty() Returns - true if this set is empty Args - none Function - checks if this set is empty
Usage - $set->equals($another_set) Returns - either 1 (true) or 0 (false) Args - the set (Core::Util::Set) to compare with Function - tells whether this set is equal to the given one
OBO::Util::ObjectIdSet - A Set implementation of object IDs.
use OBO::Util::ObjectIdSet;
use strict;
my $my_set = OBO::Util::ObjectIdSet->new();
$my_set->add("APO:P0000001");
print "contains" if ($my_set->contains("APO:P0000001"));
$my_set->add_all("APO:P0000002", "APO:P0000003", "APO:P0000004");
print "contains" if ($my_set->contains("APO:P0000002") && $my_set->contains("APO:P0000003") && $my_set->contains("APO:P0000004"));
foreach ($my_set->get_set()) {
print $_, "\n";
}
print "\nContained!\n" if ($my_set->contains("APO:P0000001"));
my $my_set2 = OBO::Util::ObjectIdSet->new();
$my_set2->add_all("APO:P0000001", "APO:P0000002", "APO:P0000003", "APO:P0000004");
print "contains" if ($my_set2->contains("APO:P0000002") && $my_set->contains("APO:P0000003") && $my_set->contains("APO:P0000004"));
$my_set->equals($my_set2);
$my_set2->size();
$my_set2->remove("APO:P0000003");
print "contains" if ($my_set2->contains("APO:P0000001") && $my_set->contains("APO:P0000002") && $my_set->contains("APO:P0000004"));
$my_set2->remove("APO:P0000005");
$my_set2->clear();
print "not contains" if (!$my_set2->contains("APO:P0000001") || !$my_set->contains("APO:P0000002") || !$my_set->contains("APO:P0000004"));
$my_set2->is_empty();
A collection that contains no duplicate elements. More formally, sets contain no pair of elements $e1 and $e2 such that $e1->equals($e2). As implied by its name, this interface models the mathematical set abstraction.
Erick Antezana, <erick.antezana -@- gmail.com>
Copyright (C) 2007, 2008, 2009, 2010 by Erick Antezana
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.7 or, at your option, any later version of Perl 5 you may have available.
To install OBO::Util::Set, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OBO::Util::Set
CPAN shell
perl -MCPAN -e shell install OBO::Util::Set
For more information on module installation, please visit the detailed CPAN module installation guide.