-
-
27 Feb 2018 08:38:55 UTC
- Distribution: Clownfish
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Clone repository
- Issues
- Testers (1313 / 0 / 7)
- Kwalitee
Bus factor: 0- License: apache_2_0
- Perl: v5.8.3
- Activity
24 month- Tools
- Download (230.31KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- The Apache Lucy Project <dev at lucy dot apache dot org>
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Clownfish::Vector - Variable-sized array.
SYNOPSIS
my $vector = Clownfish::Vector->new; $vector->store($tick, $value); my $value = $vector->fetch($tick);
DESCRIPTION
CONSTRUCTORS
new
my $vector = Clownfish::Vector->new( capacity => $capacity, # default: 0 );
Return a new Vector.
capacity - Initial number of elements that the object will be able to hold before reallocation.
METHODS
push
$vector->push($element); $vector->push(); # default: undef
Push an item onto the end of a Vector.
push_all
$vector->push_all($other);
Push all the elements of another Vector onto the end of this one.
pop
my $obj = $vector->pop();
Pop an item off of the end of a Vector.
Returns: the element or undef if the Vector is empty.
insert
$vector->insert( tick => $tick, # required element => $element, # default: undef );
Insert an element at
tick
moving the following elements.insert_all
$vector->insert_all( tick => $tick, # required other => $other, # required );
Inserts elements from
other
vector attick
moving the following elements.fetch
my $obj = $vector->fetch($tick);
Fetch the element at
tick
.Returns: the element or undef if
tick
is out of bounds.store
$vector->store($tick, $elem)
Store an element at index
tick
, possibly displacing an existing element.delete
my $obj = $vector->delete($tick);
Replace an element in the Vector with undef and return it.
Returns: the element stored at
tick
or undef iftick
is out of bounds.excise
$vector->excise( offset => $offset, # required length => $length, # required );
Remove
length
elements from the Vector, starting atoffset
. Move elements over to fill in the gap.clone
my $arrayref = $vector->clone();
Clone the Vector but merely increment the refcounts of its elements rather than clone them.
sort
$vector->sort();
Sort the Vector. Sort order is guaranteed to be stable: the relative order of elements which compare as equal will not change.
resize
$vector->resize($size);
Set the size for the Vector. If the new size is larger than the current size, grow the object to accommodate undef elements; if smaller than the current size, decrement and discard truncated elements.
clear
$vector->clear();
Empty the Vector.
get_size
my $int = $vector->get_size();
Return the size of the Vector.
slice
my $arrayref = $vector->slice( offset => $offset, # required length => $length, # required );
Return a slice of the Vector consisting of elements from a contiguous range. If the specified range is out of bounds, return a slice with fewer elements – potentially none.
offset - The index of the element to start at.
length - The maximum number of elements to slice.
INHERITANCE
Clownfish::Vector isa Clownfish::Obj.
Module Install Instructions
To install Clownfish, copy and paste the appropriate command in to your terminal.
cpanm Clownfish
perl -MCPAN -e shell install Clownfish
For more information on module installation, please visit the detailed CPAN module installation guide.