[Project_owners] how to implement bounded stack in javascript?

Eric H. Jung eric.jung at yahoo.com
Fri Apr 14 20:27:54 EDT 2006


I'm trying to implement a custom <tree/> view which displays the most recent 500 log messages
(row0 = most recent, row499 = oldest). What's the most efficient way to implement a bounded stack
(LIFO buffer) in javascript?

I was thinking this:

var boundedStack = new Array(500);
function push(o) {
  if (boundedStack.unshift(o) > 500)

Is there anything more efficient? I'm looking for the most performant implementation.

Thank you for any advice,
Eric H. Jung
FoxyProxy--Take Back Your Privacy!  (Coming This Weekend)

More information about the Project_owners mailing list