Documentation ¶
Index ¶
- Variables
- type Error
- type Queue
- func (q *Queue) Add(x Queueable)
- func (q *Queue) AddSlice(s []Queueable)
- func (q *Queue) Collection() []Queueable
- func (q *Queue) Len() int
- func (q *Queue) Less(i, j int) bool
- func (q *Queue) Member(i int) (m Queueable, err error)
- func (q *Queue) Pop() interface{}
- func (q *Queue) Push(x interface{})
- func (q *Queue) Remove() interface{}
- func (q *Queue) Swap(i, j int)
- type Queueable
Constants ¶
This section is empty.
Variables ¶
var ( QERR_OUT_OF_BOUNDS = Error("This index is out of bounds.") QERR_NOT_QUEUEABLE = Error("Object does not implemnt Queueable interface.") )
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the basic priority queue structure
func (*Queue) AddSlice ¶
AddSlice pushes a slice of queueable objects onto the Q and then min-heaps the elements. complexity is O(n) where n = q.Len().
func (*Queue) Collection ¶
Return the full collection (possibly unsorted & not min-heap initialised) use heap.Init(q) or sort.Sort(q) if you need the members sorted or min-heaped
func (*Queue) Pop ¶
func (q *Queue) Pop() interface{}
Pop satisfies the heap interface, do not use directly
NOTE: This method pops elements from the Q and does not min-heapify the elements. User container/heap instead e.g. x, ok := heap.Pop(q).(Queueable)
func (*Queue) Push ¶
func (q *Queue) Push(x interface{})
Push satisfies the heap interface, do not use directly.
NOTE: This method simply appends to the Q and does not min-heapify or sort the elements. Use Add(x Queueable) or container/heap instead e.g. heap.Push(q, x interface{}). Additionally this method panics if your Q element does not satisfy the Queueable interface.