Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DisjointSet ¶
type DisjointSet struct { Value interface{} // contains filtered or unexported fields }
DisjointSet is a data structure that tracks a set of elements partitioned into a number of non-overlapping (disjoint) subsets.
func NewDisjointSet ¶
func NewDisjointSet(v interface{}) *DisjointSet
NewDisjointSet returns a disjoint-set initialized to contain only value v.
func Union ¶
func Union(x, y *DisjointSet) *DisjointSet
Union finds thes the representative element of x and y and merges the smaller of the two sets into the other.
func (*DisjointSet) Find ¶
func (d *DisjointSet) Find() *DisjointSet
Find finds the root (or representative element) of disjoint-set d.
type Element ¶
type Element struct { Value interface{} // contains filtered or unexported fields }
Element is an element of a queue.
type Frame ¶
type Frame struct { Value interface{} // contains filtered or unexported fields }
Frame is an element of a stack.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue represents an ordered collection of elements that can be accessed in a priority-first manner. Elements with a higher priority are retrieved before elements with a lower priority.
func NewPriorityQueue ¶
func NewPriorityQueue(n int) *PriorityQueue
NewPriorityQueue returns a priority queue of size n.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
Len returns the number of elements in the queue.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
Pop removes the element with the highest priority and returns its value.
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(v interface{}, p int)
Push inserts a new element e with value v and priority p to the queue.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue represents an ordered collection of elements that can be accessed in a first-in, first-out manner. The zero value for Queue is an empty queue ready to use.
func (*Queue) Dequeue ¶
func (q *Queue) Dequeue() interface{}
Dequeue removes and returns the front-most element of queue q.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents an ordered collection of elements that can be accessed in a last-in, first-out manner. The zero value for Stack is an empty stack ready to use.
func (*Stack) Pop ¶
func (s *Stack) Pop() interface{}
Pop removes and returns the top-most frame of stack s.