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

version» Context lines:

pike.git/lib/modules/ADT.pmod/Stack.pike:1:   #pike __REAL_VERSION__    - // $Id: Stack.pike,v 1.10 2003/08/22 14:23:13 nilsson Exp $ + // $Id: Stack.pike,v 1.11 2005/12/13 23:34:51 nilsson 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:123:   //! A stack added with another stack yields a third   //! a third stack will all the stack elements from   //! the two first stacks.   this_program `+(this_program s) {    array elem = arr[..ptr-1]+values(s);    this_program ns = this_program(1);    ns->set_stack(elem);    return ns;   }    + mixed cast(string to) { +  switch(to) { +  case "array": +  return _values(); +  default: +  error("Cannot cast to %s.\n", to); +  } + } +    string _sprintf(int t) {    return t=='O' && sprintf("%O%O", this_program, _values());   }