pike.git / lib / modules / ADT.pmod / Stack.pike

version» Context lines:

pike.git/lib/modules/ADT.pmod/Stack.pike:1: + // $Id: Stack.pike,v 1.4 2002/03/18 01:29:48 mast Exp $      //! This class implements a simple stack. Instead of adding and removing   //! elements to an array, and thus making it vary in size for every push   //! and pop operation, this stack tries to keep the stack size constant.   //! If however the stack risks to overflow, it will allocate double its   //! current size, i.e. pushing an element on an full 32 slot stack will   //! result in a 64 slot stack with 33 elements.      int ptr;   array arr;
pike.git/lib/modules/ADT.pmod/Stack.pike:41:    }    } else {    if (ptr > 0) {    ptr--;    }    }   }      //! Pops and returns entry @[val] from the stack, counting   //! from the top. If no value is given the top element is - //! popped and returned. All poped entries are freed from + //! popped and returned. All popped entries are freed from   //! the stack.   mixed pop(void|int val)   {    mixed foo;       if (val) {    if (ptr <= 0) {    error("Stack underflow\n");    }