Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re-orderable keyed access structure?

by Limbic~Region (Chancellor)
on Aug 14, 2004 at 14:17 UTC ( #382965=note: print w/replies, xml ) Need Help??


in reply to Re-orderable keyed access structure?

BrowserUk,
My module Tie::Hash::Sorted does most of what you are asking for, albeit some stuff is "under the covers". You are welcome to abuse it in any way you want for your purposes or you can send me a feature request and I will do it when I have a chance.

Cheers - L~R

  • Comment on Re: Re-orderable keyed access structure?

Replies are listed 'Best First'.
Re^2: Re-orderable keyed access structure?
by BrowserUk (Pope) on Aug 14, 2004 at 15:17 UTC

    Thanks L~R, but it you take a look at 382970, you'll see that the "ordering" isn't sorting.

    The re-ordering occurs when a hash element is accessed, according to a hueristic that includes (for example), if a hash element is required that isn't currently being held in the (internal) array, then the lowest ordered item in the array may be discarded to accomodate the called for item. However, an item's position in the array is adjusted each time it is accessed (always by key).

    If an item has been STORE'd to, the underlying item will have been modified and so discarding it from the array will require an update to the backing store first.

    If the item has only ever been FETCH'd, discarding it is cheaper as the backing store doesn't need an update.

    The hueristic can also take into account the frequency of access and/or the recentness(better word?) (or otherwise), of it's last access.

    As you can see, this doesn't easily translate into a sort criteria that could be used with your module. (Unless you can see a way :).

    Thanks again.


    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
      BrowserUk,
      Ok, in light of this further explanation - Tie::Hash::Sorted isn't for you. To be honest, I only read the root node in the thread which didn't include these details. I do want to point out that sorted can be equal to ordered if the sort routine uses a lexical that defines that order. That is one of the great things about the module - the sort routine can be anything you dream up to include defining the specific order 1 by 1.

      Cheers - L~R

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2020-02-23 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (102 votes). Check out past polls.

    Notices?