PHP SPL standard library data structure stack (splstack) Introduction, Splsplstack
A stack is a special linear table because it can only insert or delete elements at one end of a linear table (that is, the stack and the stack)
Splstack is the inherited doubly linked list (spldoublylinkedlist) implementation stack.
The class summary is as follows:
Simple to use as follows:
Think of the stack as an inverted array $stack = new Splstack ();/** * The difference between a visible stack and a doubly linked list is that Iteratormode changes, the iteratormode of the stack can only be: * (1) spldoublylinkedlist :: It_mode_lifo | Spldoublylinkedlist::it_mode_keep (default, data save after Iteration) * (2) Spldoublylinkedlist::it_mode_lifo | Spldoublylinkedlist::it_mode_delete (data deduplication after iteration) */$stack->setiteratormode (Spldoublylinkedlist::it_mode_lifo | Spldoublylinkedlist::it_mode_delete); $stack->push (' a '); $stack->push (' B '); $stack->push (' C '); $stack->pop (); The stack $stack->offsetset (0, ' first '),//index 0 is the last element, foreach ($stack as $item) {echo $item. Php_eol; First A} print_r ($stack); Test Iteratormode
http://www.bkjia.com/PHPjc/998569.html www.bkjia.com true http://www.bkjia.com/PHPjc/998569.html techarticle the PHP SPL standard library data structure stack (splstack) introduces that the Splsplstack stack (stack) is a special linear table because it can only insert or delete elements at one end of a linear table (that is, the stack and out ...)