in reply to Designing a cache data structure

You want a linked list. Lots of ways to do such. I'll be posting the one I wrote soon.

- tye        

  • Comment on Re: Designing a cache data structure (linked list)

Replies are listed 'Best First'.
Re^2: Designing a cache data structure (linked list)
by Aristotle (Chancellor) on Feb 21, 2005 at 05:43 UTC

    I dunno. I got pretty badly burned by splice trying to compete using a heap, and that didn't require managing references, just index math. How do you intend to set this up?

    Makeshifts last the longest.

      "O(1) Perl opcodes vs. splice" doesn't really compare to "O(log(N)) Perl opcodes vs. splice", especially when the constant multiplier for the O(1) is quite small.

      Splice might be efficient enough that the point where splice's O(N) nature finally takes over the small constant is a fairly large N.

      But I consider trying to optimize the simple O(1) linked list to be micro optimization and I don't plan to spend time futzing with benchmarks to see if an O(N) solution is a bit faster for the cache sizes I predict (perhaps quite inaccurately, in the long run).

      - tye