gtreap: Index | Files

package gtreap

import ""


Package Files


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 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) 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 116 packages. Updated 2020-04-26. Refresh now. Tools for package owners.