Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comparator ¶
type Comparator func(a, b interface{}) int
Comparator is a function that compares two values return 0 if they are equal return -1 if a < b return 1 if a > b
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is an iterator for a sorted window
type SortedMinWindow ¶
type SortedMinWindow struct {
// contains filtered or unexported fields
}
SortedMinWindow is used to sort a stream of values when that stream may be too large to buffer in memory If limit is positive it sets the window size. If limit is negative or zero there is no limit and the window will grow to hold the entire data set in memory.
func New ¶
func New(comparator Comparator, opts ...option) *SortedMinWindow
New creates a new SortedMinWindow.
func (*SortedMinWindow) Insert ¶
func (sortedWindow *SortedMinWindow) Insert(obj interface{})
Insert attempts to insert obj into the window. If limit is <= 0 it will be inserted. If limit > 0 and size has not yet hit limit then it will be inserted. If limit > 0 and size has hit limit and obj >= the max value in the window then it will not be inserted. If limit > 0 and size has hit limit and obj < the max value in the window then it will be inserted and the max value will be removed.
func (*SortedMinWindow) Iterator ¶
func (sortedWindow *SortedMinWindow) Iterator() *Iterator
Iterator returns an iterator for the window that returns values in ascending order
func (*SortedMinWindow) Size ¶
func (sortedWindow *SortedMinWindow) Size() int
Size returns the number of elements in the window
Directories ¶
Path | Synopsis |
---|---|
Package redblacktree implements a red-black tree.
|
Package redblacktree implements a red-black tree. |