php SPL标准库数据结构

WBOY
Release: 2016-06-23 13:16:41
Original
750 people have browsed it

//栈(后进先出)$stack =new SplStack();$stack->push("data1");$stack->push("data2");echo $stack->pop();echo $stack->pop();//队列(先进先出)$queue = new SplQueue();$queue->enqueue("aaaaaa");$queue->enqueue("bbbbbb");echo $queue->dequeue();echo $queue->dequeue();//最小堆(从小到大)$heap = new SplMinHeap();$heap->insert("555");$heap->insert("444");echo $heap->extract();echo $heap->extract();//最大堆(从大到小)$maxHeap = new SplMaxHeap();$maxHeap->insert(888);$maxHeap->insert(999);echo $maxHeap->extract();echo $maxHeap->extract();//固定长度的数组$array = new SplFixedArray(10);$array[0] = 111;$array[8] = 888;var_dump($array);
Copy after login



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template