Abstract Priority Queue

It implements a priority queue. Please go to "Data Structures and Algorithms", Aho, Hopcroft, and Ullman, Addison-Wesley, 1983 (corrected 1987 edition), for implementation details.

It provides O(log(N)) time of put/pop operations, where N is a size of queue

category Zend
package Zend_Search_Lucene
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Clear queue

clear() 

Removes and return least element of the queue

pop() : mixed

O(log(N)) time

Returns

mixed

Add element to the queue

put(mixed $element) 

O(log(N)) time

Parameters

$element

mixed

Return least element of the queue

top() : mixed

Constant time

Returns

mixed

Compare elements

_less(mixed $el1, mixed $el2) : boolean

Returns true, if $el1 is less than $el2; else otherwise

Parameters

$el1

mixed

$el2

mixed

Returns

boolean

 Properties

 

Queue heap

$_heap : array

Default

array()

Heap contains balanced partial ordered binary tree represented in array [0] - top of the tree [1] - first child of [0] [2] - second child of [0] ... [2n + 1] - first child of [n] [2n + 2] - second child of [n]