NAME
Set::SortedArray - sets stored as sorted arrays for speed
VERSION
Version 0.0.1
SYNOPSIS
use Set::SortedArray;
my $s = Set::SortedArray->new( qw/ d b c a e /);
my $t = Set::SortedArray->new_presorted( qw/ b c e f g / );
print $s->as_string, "\n";
print $s, "\n";
$u = $s->union($t);
$i = $s->intersection($t);
$d = $s->difference($t);
$e = $s->symmetric_difference($t);
$a = $s->asymmetric_difference($t);
$v = $s->unique($t);
$u = $s + $t; # union
$i = $s * $t; # intersection
$d = $s - $t; # difference
$e = $s % $t; # symmetric_difference
$v = $s / $t; # unique
$eq = $s->is_equal($t);
$dj = $s->is_disjoint($t);
$ps = $s->is_proper_subset($t);
$pS = $s->is_proper_superset($t);
$is = $s->is_subset($t);
$iS = $s->is_superset($t);
$eq = $s == $t; # equal
$dj = $s != $t; # disjoint
$ps = $s < $t; # is_proper_subset
$pS = $s > $t; # is_proper_superset
$is = $s <= $t; # is_subset
$iS = $s >= $t; # is_superset
# amalgam of a few of the above
$cmp = $s->compare($t);
$cmp = $s <=> $t;
DESCRIPTION
Create a set that is stored as a sorted array. Similar to Set::Scalar, except optimized for speed and memory.
CONSTRUCTORS
new
$set = Set::SortedArray->new();
$set = Set::SortedArray->new(@members);
new_presorted
$set = Set::SortedArray->new_presorted(@members);
Quicker than new, but doesn't sort data.
MODIFYING
TODO
DISPLAYING
as_string
print $s->as_string, "\n";
print $s, "\n";
as_string_callback
Set::SortedArray->as_string_callback(sub { ... });
QUERYING
members
size
DERIVING
union
$u = $s->union($t);
$u = $s->union($t, $v);
$u = $s + $t;
$u = $s + $t + $v; # inefficient
intersection
$i = $s->intersection($t);
$i = $s->intersection($t, $u);
$i = $s * $t;
$i = $s * $t * $u; # inefficient
difference
$d = $s->difference($t);
$d = $s - $t;
symmetric_difference
$e = $s->symmetric_difference($t);
$e = $s % $t;
asymmetric_difference
$a = $s->asymmetric_difference($t);
Returns [ $s - $t, $t - $s ], but more efficiently.
unique
$v = $s->unique($t);
$v = $s / $t;
COMPARING
is_equal
$eq = $s->is_equal($t);
$eq = $s == $t;
is_disjoint
$dj = $s->is_disjoint($t);
$dj = $s != $t;
is_proper_subset
$ps = $s->is_proper_subset($t);
$ps = $s < $t;
is_proper_superset
$pS = $s->is_proper_superset($t);
$pS = $s > $t;
is_subset
$is = $s->is_subset($t);
$is = $s <= $t;
is_superset
$iS = $s->is_superset($t);
$iS = $s >= $t;
compare
$cmp = $s->compare($t);
$cmp = $s <=> $t;
compare
returns:
0 if $s == $t
1 if $s > $t
-1 if $s < $t
() otherwise
AUTHOR
"Kevin Galinsky", kgalinsky plus cpan at gmail dot com
BUGS
Please report any bugs or feature requests to bug-set-sortedarray at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Set-SortedArray. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Set::SortedArray
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2011 "Kevin Galinsky".
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.