Common data structures for SPL standard libraries

Source: Internet
Author: User

stack data Structure
1 $stack=NewSplstack ();//stack data Structure-advanced back-out2$stack->push (' data1 ');//into the stack3 $stack->push (' data2 ');//into the stack4 Echo $stack->pop ();//out of Stack->data25 Echo $stack->pop ();//out of Stack->data1

Queue data Structure
1 $queue=NewSplqueue ();//FIFO, queue data structure2 $queue->enqueue (' data1 ');//into Row3 $queue->enqueue (' data2 ');//into Row4 Echo $queue->dequeue ();//dequeue->data15 Echo $queue->dequeue ();//dequeue->data2

Heap Data Structures
1 $heap=NewSplminheap ();//Heap Data Structures2 $heap->insert (' data1 ');//Store3 $heap->insert (' data2 ');//Store4 Echo $heap-Extract();//Remove->data15 Echo $heap-Extract();//Remove->data2

Fixed-length array data structure
1 $array=NewSplfixedarray (10);//fixed-length array data structure with a declaration length of ten2 $array[0] = 0;3 $array[9] = 9;4 Var_dump($array); 5 //object (Splfixedarray) #1 (Ten) {[0]=> int (0) [1]=> null [2]=> null [3]=> null [4]=> null [5]=> NULL [ 6]=> null [7]=> null [8]=> null [9]=> INT (9)}6 //Subscript 1-8 allocates memory space, whether or not used

Common data structures for SPL standard libraries

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.