TipJar::sparse::array::perl::hashbased - reference implementation of sparse array
use TipJar::sparse::array::perl::hashbased; sparse my @S; ...
An implementation of a sparse array tie class based on a Perl hash. This module is intended as a reference implementation for testing, and other modules providing the same semantics but better performance may be forthcoming later.
This module efficiently provdes correct delete behavior, which is to adjust the size of the array down to the last existing element when the top element is deleted, by maintaining a sorted array of existing keys.
delete
the splice handler could be improved. Currently it avoids specifically handling all the possibilities by always renumbering existing elements from the splice point up, then rebuilds the sorted list of existing elements.
splice
keys are kept relative to an adjusting offset to support fast shift/unshift operations.
shift
unshift
The sparse function is sugar to tie its array argument into this class.
sparse
David Nicol
Copyright (C) 2011 by David Nicol / TipJar LLC
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
To install TipJar::sparse::array::perl::hashbased, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TipJar::sparse::array::perl::hashbased
CPAN shell
perl -MCPAN -e shell install TipJar::sparse::array::perl::hashbased
For more information on module installation, please visit the detailed CPAN module installation guide.