Documentation ¶
Index ¶
- Constants
- func NewPriorityQueue(comparator Comparator, order Order) *priorityQueue
- func NewPriorityQueueWithCap(capacity int, comparator Comparator, order Order) *priorityQueue
- func NewPriorityQueueWithElems(elems []interface{}, comparator Comparator, order Order) *priorityQueue
- type Comparator
- type Order
- type Queue
Constants ¶
View Source
const ( ASC Order = 1 // asc sort. DESC Order = -1 // desc sort. MaxCap int = (1 << 31) - 2 // position with index 0 is not used. DefaultCap int = (1 << 6) + 1 // default cap is 64 )
Variables ¶
This section is empty.
Functions ¶
func NewPriorityQueue ¶
func NewPriorityQueue(comparator Comparator, order Order) *priorityQueue
func NewPriorityQueueWithCap ¶
func NewPriorityQueueWithCap(capacity int, comparator Comparator, order Order) *priorityQueue
func NewPriorityQueueWithElems ¶
func NewPriorityQueueWithElems(elems []interface{}, comparator Comparator, order Order) *priorityQueue
Types ¶
type Comparator ¶
type Comparator func(interface{}, interface{}) int
type Queue ¶
type Queue interface { // remove and return the first element of queue. PollFirst() interface{} // remove and return the last element of queue. PollLast() interface{} // return the first element of queue. PeekFirst() interface{} // return the last element of queue; PeekLast() interface{} // insert element to the head of queue. OfferFirst(interface{}) bool // insert element to the tail of queue. OfferLast(interface{}) bool // the same as PollFirst. RemoveFirst() interface{} // the same as PollLast. RemoveLast() interface{} }
Queue defines the actions of queuq.
Click to show internal directories.
Click to hide internal directories.