Is there a “canonical” (pure-)perl implementation of a tree-based ordered key-value storage with O(log(n)) access time?
I’ve tried searching for “tree” on CPAN but haven’t got much insight from that.
This question inspired me to post my own.
EDIT: So the question was unclearly stated.
What I’m looking for is a storage that barely does what a %hash would do, but maintains the order of its keys at a price of worse algorithmic complexity. All structures with such properties I know so far are based on some kind of tree (B-tree, red-black tree etc), hence the title.
Here’s a pseudocode example of what I’d like to see:
my $set = Some::Module->new();
$set->store( foo=>1 );
$set->store( bar=>2 );
$set->fetch( "foo" ); # 1
$set->keys(); # bar, foo and not foo, bar
$set->keysBetween( undef, "baz" ); # bar only
Tie::IxHashis theperlfaq4recommendation:Also try searching for “tie hash order” on CPAN if this module doesn’t cut the mustard.