Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Why is a hash the default "object" in oo perl?

by nothingmuch (Priest)
on Jul 18, 2004 at 12:56 UTC ( #375372=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Why is a hash the default "object" in oo perl?
in thread Why is a hash the default "object" in oo perl?

I once had an LRU cache purge itself using DESTROY on linked list nodes, that knew how to delete themselves from a hash. The only way I found was to tell the nodes which lookup key they had.

Retrospectively i would have the hash point to dually linked list nodes, which knew their keys too. Then each access would not create a new node, but rather bubble it up. That way the linked list doesn't grow.

To purge either implementation, you just pop off the linked list, and let the ref count reach zero.

-nuffin
zz zZ Z Z #!perl


Comment on Re^3: Why is a hash the default "object" in oo perl?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-09-19 22:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls