Home  >  Article  >  Backend Development  >  php SPL标准库数据结构

php SPL标准库数据结构

WBOY
WBOYOriginal
2016-06-23 13:16:41714browse

//栈(后进先出)$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);



Statement:
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