Documentation ¶
Index ¶
- type Heap
- func (heap *Heap) Clear()
- func (heap *Heap) Empty() bool
- func (heap *Heap) Iterator() Iterator
- func (heap *Heap) Peek() (value interface{}, ok bool)
- func (heap *Heap) Pop() (value interface{}, ok bool)
- func (heap *Heap) Push(value interface{})
- func (heap *Heap) Size() int
- func (heap *Heap) String() string
- func (heap *Heap) Values() []interface{}
- type Iterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heap ¶
type Heap struct { Comparator utils.Comparator // contains filtered or unexported fields }
func NewWith ¶
func NewWith(comparator utils.Comparator) *Heap
Instantiates a new empty heap tree with the custom comparator.
func NewWithIntComparator ¶
func NewWithIntComparator() *Heap
Instantiates a new empty heap with the IntComparator, i.e. elements are of type int.
func NewWithStringComparator ¶
func NewWithStringComparator() *Heap
Instantiates a new empty heap with the StringComparator, i.e. elements are of type string.
func (*Heap) Peek ¶
Returns top element on the heap without removing it, or nil if heap is empty. Second return parameter is true, unless the heap was empty and there was nothing to peek.
func (*Heap) Pop ¶
Pops (removes) top element on heap and returns it, or nil if heap is empty. Second return parameter is true, unless the heap was empty and there was nothing to pop.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
func (*Iterator) Index ¶
Returns the current element's index. Does not modify the state of the iterator.