Set::IntSpan::Island

Set::IntSpan::Island is a Perl extension for Set::IntSpan to handle islands and covers.
Download

Set::IntSpan::Island Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Martin Krzywinski
  • Publisher web site:
  • http://search.cpan.org/~martink/Set-IntSpan-Island-0.03/Island.pm

Set::IntSpan::Island Tags


Set::IntSpan::Island Description

Set::IntSpan::Island is a Perl extension for Set::IntSpan to handle islands and covers. Set::IntSpan::Island is a Perl extension for Set::IntSpan to handle islands and covers.SYNOPSIS use Set::IntSpan::Island # inherits normal behaviour from Set::IntSpan $set = Set::IntSpan::Island->new( $set_spec ); # special two-value input creates a range a-b $set = Set::IntSpan::Island->new( $a,$b ); # equivalent to $set->cardinality($another_set)->size; if ($set->overlap( $another_set )) { ... } # negative if overlap, positive if no overlap $distance = $set->distance( $another_set ); # remove islands shorter than $minlength $set = $set->remove_short( $minlength ); # fill holes up to $maxholesize $set = $set->fill( $maxholesize ); # return a set composed of islands of $set that overlap $another_set $set = $set->find_island( $another_set ); # return a set comopsed of the nearest non-overlapping island(s) to $another_set $set = $set->nearest_island( $another_set ); # construct a list of covers by exhaustively intersecting all sets @covers = Set::IntSpan::Island->extract_cover( { id1=>$set1, id2=>set2, ... } ); for $cover (@covers) { ($coverset,@ids) = ($cover->, @{$cover->}); print "cover",$coverset->run_list,"contains sets",join(",",@ids); }This module extends the Set::IntSpan module by Steve McDougall. It implementing methods that are specific to islands and covers. Set::IntSpan::Island inherits from Set::IntSpan.TerminologyAn integer set, as represented by Set::IntSpan, is a collection of islands (or spans) on the integer line ...-----xxxx----xxxxxxxx---xxxxxxxx---xx---x----....Islands are disjoint and contiguous, by definition, and may be represented by their own Set::IntSpan object. Regions not in the set that fall between adjacent spans are termed holes. For example, the integer set above is composed of 5 islands and 4 holes. The two infinite regions on either side of the set are not counted as holes within the context of this module.METHODS$set = Set::IntSpan::Island->new( $set_spec )Constructs a set using the set specification as supported by Set::IntSpan.$set = Set::IntSpan::Island->new( $a, $b )Extension to Set::IntSpan new method, this double-argument version creates a set formed by the range a-b. This is equivalent to $set = Set::IntSpan::Island->new("$a-$b")but permits initialization from a list instead of a string.$set_copy = $set->duplicate()Creates a copy of $set.$overlap_amount = $set->overlap( $another_set );Returns the size of intersection of two sets. Equivalent to $set->intersect( $another_set )->size;$d = $set->distance( $another_set )Returns the distance between sets, measured as follows. If the sets overlap, then the distance is negative and given by $d = - $set->overlap( $another_set )If the sets do not overlap, $d is positive and given by the distance on the integer line between the two closest islands of the sets.$d = $set->sets()Returns all spans in $set as Set::IntSpan::Island objects. This method overrides the sets method in Set::IntSpan in order to return sets as Set::IntSpan::Island objects.$set = $set->excise( $minlength )Removes all islands within $set smaller than $minlength.$set = $set->fill( $maxlength )Fills in all holes in $set smaller than $maxlength.$set = $set->find_islands( $integer )Returns a set containing the island in $set containing $integer. If $integer is not in $set, an empty set is returned.$set = $set->find_islands( $another_set )Returns a set containing all islands in $set intersecting $another_set. If $set and $another_set have an empty intersection, an empty set is returned.$set = $set->nearest_island( $integer )Returns the nearest island(s) in $set that contains, but does not overlap with, $integer. If $integer lies exactly between two islands, then the returned set contains these two islands.$set = $set->nearest_island( $another_set );Returns the nearest island(s) in $set that intersects, but does not overlap with, $another_set. If $another_set lies exactly between two islands, then the returned set contains these two islands.$cover_data = Set::IntSpan::Island->extract_covers( $set_hash_ref )Given a $set_hash reference { id1=>$set1, id2=>$set2, ..., idn=>$setn}where $setj is a finite Set::IntSpan::Island object and idj is a unique key, extract_covers performs an exhaustive intersection of all sets and returns a list of all covers and set memberships. For example, given the id/runlist combination a 10-15 b 12 c 14-20 d 25The covers are 10-11 a 12 a b 13 a 14-15 a c 16-20 c 21-24 - 25 dThe cover data is returned as an array reference and its structure is ], ], ... ]If a cover contains no elements, then its entry is ]$island = $set->num_islandsReturns the number of islands in the set.$island = $set->at_island( $island_index )Returns the island indexed by $island_index. Islands are 0-indexed. For a set with N islands, the first island (ordered left-to-right) has index 0 and the last island has index N-1.If $island_index is negative, counting is done back from the last island (c.f. negative indexes of Perl arrays).$island = $set->first_islandReturns the first island of the set as a Set::IntSpan::Island object. As a side-effect, sets the iterator to the first island.If the set is empty, returns undef.$island = $set->last_islandReturns the last island of the set as a Set::IntSpan::Island object. As a side-effect, sets the iterator to the last island.If the set is empty, returns undef.$island = $set->next_islandAdvances the iterator forward by one island, and returns the next island. If the iterator is undefined (e.g. not previously set by first()), the first island is returned.Returns undef if the set is empty or if no more islands are available.$island = $set->prev_islandReverses the iterator backward by one island, and returns the previous island. If the iterator is undefined (e.g. not previously set by last()), the last island is returned.Returns undef if the set is empty or if no more islands are available.$island = $set->current_islandReturns the island at the current iterator position.Returns undef if the set is empty or if the iterator is not defined. Requirements: · Perl


Set::IntSpan::Island Related Software