aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/DoubleEndedQueue.php
diff options
context:
space:
mode:
authorHilmar R <u02@u29lx193>2021-02-28 21:06:16 +0100
committerHilmar R <u02@u29lx193>2021-03-01 18:48:11 +0100
commitc26dede97f626b52b7bf8962ed55d1dbda86abe8 (patch)
tree3c8c9bc97aa09f7ce9afe9bf467cf87bbf2c7d0b /vendor/ramsey/collection/src/DoubleEndedQueue.php
parentea3390d626f85b7293a750958bfd1b5460958365 (diff)
downloadvolse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.gz
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.bz2
volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.zip
get dev
Diffstat (limited to 'vendor/ramsey/collection/src/DoubleEndedQueue.php')
-rw-r--r--vendor/ramsey/collection/src/DoubleEndedQueue.php141
1 files changed, 20 insertions, 121 deletions
diff --git a/vendor/ramsey/collection/src/DoubleEndedQueue.php b/vendor/ramsey/collection/src/DoubleEndedQueue.php
index 4eb4dbeab..6ebdca5ad 100644
--- a/vendor/ramsey/collection/src/DoubleEndedQueue.php
+++ b/vendor/ramsey/collection/src/DoubleEndedQueue.php
@@ -20,6 +20,10 @@ use Ramsey\Collection\Exception\NoSuchElementException;
/**
* This class provides a basic implementation of `DoubleEndedQueueInterface`, to
* minimize the effort required to implement this interface.
+ *
+ * @template T
+ * @template-extends Queue<T>
+ * @template-implements DoubleEndedQueueInterface<T>
*/
class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
{
@@ -31,19 +35,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
private $tail = -1;
/**
- * Sets the given value to the given offset in the queue.
- *
- * Since arbitrary offsets may not be manipulated in a queue, this method
- * serves only to fulfill the `ArrayAccess` interface requirements. It is
- * invoked by other operations when adding values to the queue.
- *
- * @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet()
- *
- * @param mixed|null $offset The offset is ignored and is treated as `null`.
- * @param mixed $value The value to set at the given offset.
- *
- * @throws InvalidArgumentException when the value does not match the
- * specified type for this queue.
+ * @inheritDoc
*/
public function offsetSet($offset, $value): void
{
@@ -60,16 +52,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Ensures that the specified element is inserted at the front of this queue.
- *
- * @see self::offerFirst()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if this queue changed as a result of the call.
- *
- * @throws InvalidArgumentException when the value does not match the
- * specified type for this queue.
+ * @inheritDoc
*/
public function addFirst($element): bool
{
@@ -88,16 +71,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Ensures that the specified element in inserted at the end of this queue.
- *
- * @see Queue::add()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if this queue changed as a result of the call.
- *
- * @throws InvalidArgumentException when the value does not match the
- * specified type for this queue.
+ * @inheritDoc
*/
public function addLast($element): bool
{
@@ -105,13 +79,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Inserts the specified element at the front this queue.
- *
- * @see self::addFirst()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if the element was added to this queue, else `false`.
+ * @inheritDoc
*/
public function offerFirst($element): bool
{
@@ -123,14 +91,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Inserts the specified element at the end this queue.
- *
- * @see self::addLast()
- * @see Queue::offer()
- *
- * @param mixed $element The element to add to this queue.
- *
- * @return bool `true` if the element was added to this queue, else `false`.
+ * @inheritDoc
*/
public function offerLast($element): bool
{
@@ -138,17 +99,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves and removes the head of this queue.
- *
- * This method differs from `pollFirst()` only in that it throws an
- * exception if this queue is empty.
- *
- * @see self::pollFirst()
- * @see Queue::remove()
- *
- * @return mixed the head of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function removeFirst()
{
@@ -156,38 +107,21 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves and removes the tail of this queue.
- *
- * This method differs from `pollLast()` only in that it throws an exception
- * if this queue is empty.
- *
- * @see self::pollLast()
- *
- * @return mixed the tail of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function removeLast()
{
- if ($this->count() === 0) {
+ $tail = $this->pollLast();
+
+ if ($tail === null) {
throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.');
}
- $tail = $this[$this->tail];
-
- unset($this[$this->tail]);
- $this->tail--;
-
return $tail;
}
/**
- * Retrieves and removes the head of this queue, or returns `null` if this
- * queue is empty.
- *
- * @see self::removeFirst()
- *
- * @return mixed|null the head of this queue, or `null` if this queue is empty.
+ * @inheritDoc
*/
public function pollFirst()
{
@@ -195,12 +129,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves and removes the tail of this queue, or returns `null` if this
- * queue is empty.
- *
- * @see self::removeLast()
- *
- * @return mixed|null the tail of this queue, or `null` if this queue is empty.
+ * @inheritDoc
*/
public function pollLast()
{
@@ -217,17 +146,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves, but does not remove, the head of this queue.
- *
- * This method differs from `peekFirst()` only in that it throws an
- * exception if this queue is empty.
- *
- * @see self::peekFirst()
- * @see Queue::element()
- *
- * @return mixed the head of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function firstElement()
{
@@ -235,16 +154,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves, but does not remove, the tail of this queue.
- *
- * This method differs from `peekLast()` only in that it throws an exception
- * if this queue is empty.
- *
- * @see self::peekLast()
- *
- * @return mixed the tail of this queue.
- *
- * @throws NoSuchElementException if this queue is empty.
+ * @inheritDoc
*/
public function lastElement()
{
@@ -256,13 +166,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves, but does not remove, the head of this queue, or returns `null`
- * if this queue is empty.
- *
- * @see self::firstElement()
- * @see Queue::peek()
- *
- * @return mixed|null the head of this queue, or `null` if this queue is empty.
+ * @inheritDoc
*/
public function peekFirst()
{
@@ -270,12 +174,7 @@ class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface
}
/**
- * Retrieves, but does not remove, the tail of this queue, or returns `null`
- * if this queue is empty.
- *
- * @see self::lastElement()
- *
- * @return mixed|null the tail of this queue, or `null` if this queue is empty
+ * @inheritDoc
*/
public function peekLast()
{