in reply to Linked-list Style Data Structure

You are asking about alternative ways to implement "this functionality", but what is your module actually offering as functionality? Is there more than just next/previous based on named indices? If not, I'd keep the entries in an array, and use a hash to map names to indices.

The only reason to use linked lists instead of arrays is performance for inserts and deletes. But you aren't inserting or deleting.

Abigail

Replies are listed 'Best First'.
Re: Re: Linked-list Style Data Structure
by impossiblerobot (Deacon) on Oct 07, 2002 at 13:06 UTC

    Thanks, Abigail-II, for pointing out the vagueness in my question. The specific functionality that I am looking for at this point is essentially as you stated:

    • The ability to define the data structure simply (preferably using an array or list).
    • The ability to find out the name of the next or previous item based on the the current (or a named) item.

    Although I currently do not need to insert or delete elements, I might need to in the future. However, since my lists will never be that long, and I would not do it that often, I could probably still use your suggestion (and rebuild the entire index when necessary) without any noticable performance issues.

    In any case, it seems that you are advocating trying to use a data structure appropriate to the task, rather than relying on a generic structure that might be less suited. Am I understanding correctly?


    Impossible Robot
      In any case, it seems that you are advocating trying to use a data structure appropriate to the task, rather than relying on a generic structure that might be less suited. Am I understanding correctly?
      Yes, that's the Perl (and Unix) way. You have a large toolkit at your disposal, with lots of different tools. Different tools for different jobs. Use your toolkit. The saying "if all you have is a hammer, everything looks like a nail" is not at all appropriate for Perl.

      Abigail