Tim Tompkins wrote to Ben Mathews:

> Honestly, I didn't see where any of those libs would assist what the
> poster wanted to accomplish.  What's wrong with splice?

For implementing a traditional stack, the splice operation (or any
operation which has to rearrange the list every time an element is
pushed or popped) will be much more expensive than the constant-time
push() and pop(). That, and push()/pop() have the benefit of
abstracting the underlying data representation. :-)

The idea in any memory stack implementation is to not have to move the
elements. You can abstract away from that to make more sense for a
given application, but, in memory, you still want the growth end of
the stack to be variable.

If you don't buy any of that, unshift() and shift() instead, for the
O(n) versions of push() and pop(). :-)

- Ryan

-- 
  Ryan Thompson <[EMAIL PROTECTED]>

  SaskNow Technologies - http://www.sasknow.com
  901 1st Avenue North - Saskatoon, SK - S7K 1Y4

        Tel: 306-664-3600   Fax: 306-244-7037   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America

Reply via email to