Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: Re-orderable keyed access structure?

by etcshadow (Priest)
on Aug 14, 2004 at 04:21 UTC ( [id://382898]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Re-orderable keyed access structure?
in thread Re-orderable keyed access structure?

OK, so if you need to be able to get from key to payload, but not from key to index, then how about:
  • a hash of $key => $data
  • a hash of $data => $key (that is the stringification of the ref stored in $data... maybe consider making this a Tie::RefHash, if you want)
  • an array of hash keys
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re^6: Re-orderable keyed access structure?
by BrowserUk (Patriarch) on Aug 14, 2004 at 04:39 UTC

    Yes. That will do it. And it's cheap to maintain. Thankyou.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^6: Re-orderable keyed access structure?
by Aristotle (Chancellor) on Aug 14, 2004 at 05:09 UTC

    This is essentially the same as I proposed: a main data structure carrying the payload, and two auxiliary ones for bidirectionality — except you the bidirectionality in your setup is between the main and one auxiliary structure, while in mine it is between the two auxiliary structures. By doing it that there's no need for references at all.

    Makeshifts last the longest.

Re^6: Re-orderable keyed access structure?
by BrowserUk (Patriarch) on Aug 14, 2004 at 15:01 UTC

    I was premature in accepting this. Please see 382970 for the details.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://382898]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-25 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found