public function dequeue()
{
$f = $this->forwards->pop();
if ($f->isEmpty() && $this->backwards->isEmpty()) {
return self::createEmpty();
}
if ($f->isEmpty()) {
return new self($this->reversedBackwards(), PersistentStack::createEmpty(), $this->count - 1);
}
return new self($f, $this->backwards, $this->count - 1);
}