Add alias methods to StrictQueue and StrictStack

This commit is contained in:
Sebastian Meyer 2023-11-19 10:52:11 +01:00
parent e198aca844
commit afd6ec6e92
2 changed files with 50 additions and 0 deletions

View File

@ -37,6 +37,32 @@ use RuntimeException;
*/ */
class StrictQueue extends StrictList class StrictQueue extends StrictList
{ {
/**
* Dequeue an item from the queue.
* @see \SplQueue::dequeue()
*
* @return mixed The dequeued item
*/
public function dequeue(): mixed
{
return parent::shift();
}
/**
* Add an item to the queue.
* @see \SplQueue::enqueue()
*
* @param mixed $item The item to enqueue
*
* @return void
*
* @throws \InvalidArgumentException
*/
public function enqueue(mixed $item): void
{
parent::push($item);
}
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see \SplDoublyLinkedList::setIteratorMode() * @see \SplDoublyLinkedList::setIteratorMode()

View File

@ -37,6 +37,30 @@ use RuntimeException;
*/ */
class StrictStack extends StrictList class StrictStack extends StrictList
{ {
/**
* Add an item to the stack.
*
* @param mixed $item The item to stack
*
* @return void
*
* @throws \InvalidArgumentException
*/
public function stack(mixed $item): void
{
parent::push($item);
}
/**
* Unstack an item from the stack.
*
* @return mixed The unstacked item
*/
public function unstack(): mixed
{
return parent::pop();
}
/** /**
* Set the mode of iteration. * Set the mode of iteration.
* @see \SplDoublyLinkedList::setIteratorMode() * @see \SplDoublyLinkedList::setIteratorMode()