You are here

public function FastPriorityQueue::remove in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-stdlib/src/FastPriorityQueue.php \Zend\Stdlib\FastPriorityQueue::remove()

Remove an item from the queue

This is different than {@link extract()}; its purpose is to dequeue an item.

Note: this removes the first item matching the provided item found. If the same item has been added multiple times, it will not remove other instances.

Parameters

mixed $datum:

Return value

bool False if the item was not found, true otherwise.

File

vendor/zendframework/zend-stdlib/src/FastPriorityQueue.php, line 133

Class

FastPriorityQueue
This is an efficient implementation of an integer priority queue in PHP

Namespace

Zend\Stdlib

Code

public function remove($datum) {
  $this
    ->rewind();
  while ($this
    ->valid()) {
    if (current($this->values[$this->maxPriority]) === $datum) {
      $index = key($this->values[$this->maxPriority]);
      unset($this->values[$this->maxPriority][$index]);
      --$this->count;
      return true;
    }
    $this
      ->next();
  }
  return false;
}