class Deque
{
private $queue = array();
public function addFirst($item)
{
return array_unshift($this->queue, $item);
}
public function addLast($item)
{
return array_push($this->queue, $item);
}
public function removeFirst()
{
return array_shift($this->queue);
}
public function removeLast()
{
return array_pop($this->queue);
}
public function get()
{
return $this->queue;
}
}
$queue = new Deque();
$res = $queue->addFirst(1);
$res = $queue->addFirst(10);
var_dump($res);
$res = $queue->addLast(12);
$res = $queue->addLast(13);
var_dump($res);
$res = $queue->removeFirst();
var_dump($res);
$res = $queue->removeLast();
var_dump($res);
var_dump($queue->get());