gtreap: github.com/luci/gtreap Index | Files

package gtreap

import "github.com/luci/gtreap"

Index

Package Files

treap.go

type Compare Uses

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 Item Uses

type Item interface{}

Item can be anything.

type ItemVisitor Uses

type ItemVisitor func(i Item) bool

type Iterator Uses

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 Uses

func (it *Iterator) Next() (Item, bool)

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 Uses

type Treap struct {
    // contains filtered or unexported fields
}

func NewTreap Uses

func NewTreap(c Compare) *Treap

func (*Treap) Delete Uses

func (t *Treap) Delete(target Item) *Treap

func (*Treap) Get Uses

func (t *Treap) Get(target Item) Item

func (*Treap) Iterator Uses

func (t *Treap) Iterator(pivot Item) *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) Max Uses

func (t *Treap) Max() Item

func (*Treap) Min Uses

func (t *Treap) Min() Item

func (*Treap) Upsert Uses

func (t *Treap) Upsert(item Item, itemPriority int) *Treap

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 Uses

func (t *Treap) VisitAscend(pivot Item, visitor ItemVisitor)

Visit items greater-than-or-equal to the pivot.

Package gtreap is imported by 5 packages. Updated 2016-12-31. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).