<?php
class Queue
{
public$queue;
private$_queue;
public function __construct()
{
$this->queue=new SplStack();
$this->_queue =new SplStack();
}
public function push($node)
{
$this->_queue->push($node);
}
public function pop()
{
if (!$this->queue->isEmpty()) {
return$this->queue->pop();
} else {
while (!$this->_queue->isEmpty()) {
$this->queue->push($this->_queue->pop());
}
return$this->queue->pop();
}
}
}