Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
It has been some time (almost a year) since I contributed Tie::Hash::Sorted and have never received any feature requests or bug reports. This could be because no one is using it or because it does everything anyone wants. There are several minor POD nits that I have said I would fix if/when I posted a new release but that just hasn't happened. Here is a loose collection of ideas that I have thought about since releasing but don't want to add code bloat without good reason: Of course all method names are subject to change

I am just not sure if my idea of usefulness

# effectively for ( $start_key .. $end_key ) { }
is actually useful. So what do you think? If these are all garbage - are there any useful ideas you can think of that I should add or should I just leave it alone?

Cheers - L~R

Replies are listed 'Best First'.
Re: Opinions on adding functionality to Tie::Hash::Sorted
by gaal (Parson) on Jul 17, 2004 at 17:11 UTC
    Are backward and forward direction switches, or more like opposite iterate methods? If the latter, prev[ious] and next sound more standard to me. If the former, you only need one (reverse current order), *or* you need it as an addition (for completeness' sake).
      gaal,
      They would be direction switches. The reason for naming them explicitly would be so code that used them would be clear in what was going on but you are right - functionally only one is needed.

      A prev and next method were supposed to be coupled with the peek methods (which would actually change the iterator), but I got trigger happy and posted before the brain dump was complete. Thanks for mopping up the grey matter.

      Cheers - L~R

        Hmmm, I just thought of another method that might be useful: rewind, to reset the iterator. But that's probably low priority, seeing as there's no natural way to express that for unordered hashes in Perl.
Re: Opinions on adding functionality to Tie::Hash::Sorted
by brionius (Sexton) on Jul 17, 2004 at 17:33 UTC
    i think the backward/forward functionality sounds useful as well as the start/end keys. i personally haven't seen a need for the peek methods yet, but that doesn't mean that they wouldn't be useful. so i guess it depends on how much bloat they would add. =)
Re: Opinions on adding functionality to Tie::Hash::Sorted
by Limbic~Region (Chancellor) on Jul 17, 2004 at 20:49 UTC
    oh yeah...
    A get_index method. If the keys are sorted in a rank structure, it may be useful to be able to determine what rank $last_name happens to be.

    Cheers - L~R

      This could be because no one is using it or because it does everything anyone wants

      I have only used it once (several months ago) and it did everything for me. I know of a co-worker that uses it pretty frequently -- I will refer him to this thread and see what he might have to say. All the feedback I can give you is that direction switches would be quite useful. Don't really know about peek -- never needed to.

      CSUhockey3
Re: Opinions on adding functionality to Tie::Hash::Sorted
by Limbic~Region (Chancellor) on Jul 20, 2004 at 15:10 UTC
    Some more thoughts...,
    A wrap toggle should be added so that it is possible, if desired, to wrap around each end of the hash. This also begs the question should it be allowed to wrap in both directions.

    And what about....allowing the start/end key to be ordinal values (like with the get_rank idea) so you would not have to know the key names (show me 20th .. 25th place).

    Cheers - L~R