function QueueInterface::add
Ensures that this queue contains the specified element (optional operation).
Returns `true` if this queue changed as a result of the call. (Returns `false` if this queue does not permit duplicates and already contains the specified element.)
Queues that support this operation may place limitations on what elements may be added to this queue. In particular, some queues will refuse to add `null` elements, and others will impose restrictions on the type of elements that may be added. Queue classes should clearly specify in their documentation any restrictions on what elements may be added.
If a queue refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning `false`). This preserves the invariant that a queue always contains the specified element after this call returns.
Parameters
T $element The element to add to this queue.:
Return value
bool `true` if this queue changed as a result of the call.
Throws
RuntimeException if a queue refuses to add a particular element for any reason other than that it already contains the element. Implementations should use a more-specific exception that extends `\RuntimeException`.
See also
1 method overrides QueueInterface::add()
- Queue::add in vendor/
ramsey/ collection/ src/ Queue.php
File
-
vendor/
ramsey/ collection/ src/ QueueInterface.php, line 132
Class
- QueueInterface
- A queue is a collection in which the entities in the collection are kept in order.
Namespace
Ramsey\CollectionCode
public function add(mixed $element) : bool;