[Project_owners] how to implement bounded stack in javascript?

Neil neil at parkwaycc.co.uk
Sat Apr 15 13:03:21 EDT 2006


Eric H. Jung wrote:

>var boundedStack = new Array(500);
>function push(o) {
>  if (boundedStack.unshift(o) > 500)
>    boundedStack.pop();
>}
>
If you really want to preallocate 500 elements then your condition will 
always be true. Otherwise I'd just use var boundedStack = [];


More information about the Project_owners mailing list