|
|
|
Clear questions and runnable code get the best and fastest answer |
|
| PerlMonks |
Re^3: Why is a hash the default "object" in oo perl?by nothingmuch (Priest) |
| on Jul 18, 2004 at 08:56 UTC ( [id://375372]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
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
In Section
Meditations
|
|
||||||||||||||||||||||||