[Project_owners] how to implement bounded stack in javascript?

Eric H. Jung grimholtz at yahoo.com
Sat Apr 15 14:49:47 EDT 2006

Hi Axel,

> The next question to ask is, are you frequently going to hit 500 
> messages? Or are you most of the time fine with 25? That determines how 
> much of the array you want to allocate to boot with.

Yes, 500 will be hit constantly and very rapidly.

> Then I'd recommend having a 'currentIndex' member, and cycle that 
> around. That way, you never move the 499 items inside the array that you 
> didn't intend to change.

OK, I could even just push() the elements onto the end of the array but display elements in
reverse order in the <tree/>; that is fine--the tree is only displayed when the user wants to see
it, anyway. But how does a currentIndex prevent the Array from growing without bounds? I still
need o shift() or splice() every time, no? Is splice() better than shift() to remove from the

More information about the Project_owners mailing list