Documentation ¶
Index ¶
- type Compare
- type Item
- type ItemVisitor
- type Iterator
- type Treap
- func (t *Treap) Delete(target Item) *Treap
- func (t *Treap) Get(target Item) Item
- func (t *Treap) Iterator(pivot Item) *Iterator
- func (t *Treap) Max() Item
- func (t *Treap) Min() Item
- func (t *Treap) Upsert(item Item, itemPriority int) *Treap
- func (t *Treap) VisitAscend(pivot Item, visitor ItemVisitor)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compare ¶
type Compare func(a, b interface{}) int
Compare returns an integer comparing the two items lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
type ItemVisitor ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator supports iterative ascending traversal of the Treap. An Iterator is instantiated by calling a Treap's Iterator method.
func (*Iterator) Next ¶
Next returns the next Item in the iteration sequence.
If another item exists in the iteration sequence, true will be returned as the second return value; if not, false will be returned, indicating end of iteration. Additional calls to Next after end of iteration will continue to return false.
type Treap ¶
type Treap struct {
// contains filtered or unexported fields
}
func (*Treap) Iterator ¶
Iterator returns an ascending Iterator instance that is bound to this Treap. The iterator begins at "pivot" and iterates through the end of the Treap.
func (*Treap) Upsert ¶
Note: only the priority of the first insert of an item is used. Priorities from future updates on already existing items are ignored. To change the priority for an item, you need to do a Delete then an Upsert.
func (*Treap) VisitAscend ¶
func (t *Treap) VisitAscend(pivot Item, visitor ItemVisitor)
Visit items greater-than-or-equal to the pivot.