Add alias methods to StrictQueue and StrictStack
This commit is contained in:
parent
e198aca844
commit
afd6ec6e92
|
@ -37,6 +37,32 @@ use RuntimeException;
|
|||
*/
|
||||
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.
|
||||
* @see \SplDoublyLinkedList::setIteratorMode()
|
||||
|
|
|
@ -37,6 +37,30 @@ use RuntimeException;
|
|||
*/
|
||||
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.
|
||||
* @see \SplDoublyLinkedList::setIteratorMode()
|
||||
|
|
Loading…
Reference in New Issue