1. 程式人生 > >PHP SPL 四種常用的資料結構

PHP SPL 四種常用的資料結構

//固定尺寸的陣列
//$array = new SplFixedArray(10);
//$array[0] = 123;
//$array[9] = 1234;
//
//var_dump($array);

//堆
//$heap = new SplMinHeap();
//$heap->insert("data1\n");
//$heap->insert("data2\n");
//echo $heap->extract();
//echo $heap->extract();

//棧
//$stack = new SplStack();
//$stack->push("data1\n");
//$stack->push("data2\n");
//
//echo $stack->pop();
//echo $stack->pop();

//佇列
//$queue = new SplQueue();
//$queue->enqueue("data1\n");
//$queue->enqueue("data2\n");
//echo $queue->dequeue();
//echo $queue->dequeue();