首页 >后端开发 >php教程 >php SPL标准库数据结构

php SPL标准库数据结构

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-23 13:16:41782浏览

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



声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn