PHPSPL data structure note abstract

Source: Internet
Author: User
Tags spl
: This article mainly introduces the abstract of PHPSPL data structure notes. For more information about PHP tutorials, see. Php SPL (Standard PHP Library) mainly uses the following data structures: Two-Way linked list (spldoublyw.lis), stack (SplStack), queue (SplQueue), and stack (SplHeap ), splMaxHeap, SplMinHeap, SplPriorityQueue, SplFixedArray, and SplStorageObject ).

Spldoublyasklist

Data structure: (for c code, see PHP7.0.0)

Typedef struct _ spl_ptr_llist_element {struct _ spl_ptr_llist_element * prev; struct _ previous * next; int rc; // Number of times of referencing void * data; // data type} spl_ptr_llist_element; typedef struct _ spl_ptr_llist {spl_ptr_llist_element * head; spl_ptr_llist_element * tail; ddtor; // delete element reference-1 ctor; // create element reference + 1 int count; // number of elements} vertex; struct _ spl_dllist_object {zend_object std; character * llist; int traverse_position; character * traverse_pointer; zval * retval; int flags; zend_function * function identifier; zend_function * identifier; zend_function * fptr_offset_has; zend_function * fptr_offset_del; zend_function * fptr_count; zend_class_entry * ce_get_iterator; HashTable * debug_info ;};

Bidirectional linked list spldoublyinclulist implements Iterator, ArrayAccess, Countable {/* method */public _ construct (void) public void add (mixed $ index, mixed $ newval) public mixed bottom (void) public int count (void) public mixed current (void) public int getIteratorMode (void) public bool isEmpty (void) public mixed key (void) public void next (void) public bool offsetExists (mixed $ index) public mixed offsetGet (mixed $ index) public void offsetSet (mixed $ index, mixed $ newval) public void offsetUnset (mixed $ index) public mixed pop (void) public void prev (void) public void push (mixed $ value) public void rewind (void) public string serialize (void) public void setIteratorMode (int $ mode) public mixed shift (void) // delete the first element public mixed top (void) public void unserialize (string $ serialized) public void unshift (mixed $ value) // Insert the first element of value. The original first element does not delete public bool valid (void )}

Note that:

Add is a function added in version 5.5 +, and other functions are 5.3 +.

It can be seen from the data structure that although many functions contain the index element directly, if it is not in the range, an OutOfRangeException is thrown, and the actual implementation time complexity is O (n ).

For more information about the functions, see the official php Manual.

The above section describes the abstract of the php spl data structure notes, including some content. I hope to help anyone who is interested in the PHP Tutorial.

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.