in reply to maintaining a sorted structure

First of all Yes, even you can use CPAN. The basic equivalent of a C++ std::map is the hash. However, as you know, Perl hashes do not maintain order. For an ordered hash, there's Tie::IxHash, which doesn't have specific search functions, but does let you reorder the data structure by key. Even though you mention std::map (hash), you might want to check out the options in List::MoreUtils and List::Util.

Replies are listed 'Best First'.
Re^2: maintaining a sorted structure
by Limbic~Region (Chancellor) on Jan 26, 2011 at 19:01 UTC
    Sinistral,
    For an ordered hash, there's Tie::IxHash, which doesn't have specific search functions, but does let you reorder the data structure by key

    Tie::IxHash maintains insertion order which is very unlikely to be sorted order indicated by the OP. Yes, it does have rudimentary manual sort capability (asciibetical sort by keys or values). It also has the ability to manually reorder the keys arbitrarily but the user must first do the sort. If what you need is a sorted hash and not an insertion order hash, then you should use Tie::Hash::Sorted which is designed for that purpose and also has a number of optimizations.

    Disclaimer: I am the author of Tie::Hash::Sorted

    Cheers - L~R