in reply to Re: Limit the size of a hash (beware of 'add one and (re)sort and discard' algorithms)
in thread Limit the size of a hash

Yes, but if you first compare the new item with the smallest of the 10 already stored, you will very rarely add it to the set of 10 and re-sort. This would be a "conditionally discard, add, and re-sort" algorithm.

  • Comment on Re^2: Limit the size of a hash (beware of 'add one and (re)sort and discard' algorithms)

Replies are listed 'Best First'.
Re^3: Limit the size of a hash (beware of 'add one and (re)sort and discard' algorithms)
by BrowserUk (Patriarch) on Sep 05, 2013 at 15:20 UTC

    Yes. Your hand-coded insertion sort fairs much better than those using the built-in sort.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.