PHP SPL standard library data structure stack (splstack) Introduction, splsplstack_php Tutorial

Source: Internet
Author: User
Tags spl

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 ...)

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.