in reply to Re^3: Incrementing string arrays when used with foreach loops
in thread Incrementing string arrays when used with foreach loops

Wouldn't shift actually be considered dealing from the bottom of the deck? ;-}

  • Comment on Re^4: Incrementing string arrays when used with foreach loops

Replies are listed 'Best First'.
Re^5: Incrementing string arrays when used with foreach loops
by ikegami (Patriarch) on Sep 12, 2008 at 09:33 UTC

    I associate the top of the deck with the start of the deck, and thus the start of the array. And I usually see push/shift used for queues, not unshift/pop. There's nothing stopping you from using the latter, but you have to start using negative offsets to index and splice the array.

      Last I checked, push was substantially faster than unshift, which is a pretty good argument for using push/shift rather than unshift/pop.

      The first time I checked, the difference was O(1) vs O(n). I fixed that to O(1) for both, but with a significantly worse constant on unshift.