SPL data structure of php Standard Library ----- spldoublyshortlist (two-way linked list)

Source: Internet
Author: User
Tags spl rewind
: This article mainly introduces the SPL data structure of the php Standard Library ----- spldoublyshortlist (two-way linked list). For more information about PHP tutorials, see.
$ Spl = new SplDoublyLinkedList (); // instantiate the object of the two-way linked list $ spl-> push ("sdfsaf"); // add it to the top (top) (tail) of the linked list) $ spl-> push (111); $ spl-> push ('1'); $ spl-> unshift ("100 "); // the value before the bottom header is added to the bottom of the linked list. The value is $ spl-> shift (); // you can delete the bottom header) position value $ spl-> pop (); // The top Value $ spl-> top () is displayed. // Obtain the top (tail) element $ spl-> count (); // number of nodes $ spl-> isEmpty (); // whether the current value is empty, if it is null, return true $ spl-> rewind (); // move to the position of the bottom (header) $ spl-> current (); // get the value of the current node $ spl-> next (); // Move the node down $ spl-> prev (); // return to the previous node // The cyclic traversal chain table $ spl-> rewind (); while ($ name = $ spl-> current () {echo $ name. "\ n"; $ spl-> next ();} /*************************************** * *******************************/for ($ spl-> rewind (); $ spl-> valid (); $ spl-> next () {echo $ spl-> current (). "\ n" ;}var_dump ($ spl-> valid (); // if the node is a valid node, true is returned; otherwise, false is returned. // note: before $ spl-> current (), $ spl-> valid (), you must $ spl-> rewind (); otherwise, point to an empty node.

The above introduces the SPL data structure of the php Standard Library ----- SplDoublyLinkedList (two-way linked list), including the content, hope to be helpful to friends who are interested in PHP tutorials.

Related Article

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.