goroutree: github.com/ScottMansfield/goroutree Index | Files

package goroutree

import "github.com/ScottMansfield/goroutree"

Index

Package Files

comparer.go goroutree.go

Variables

var NotComparable error = errors.New("Not Comparable")

type Comparer Uses

type Comparer interface {
    // Compare yourself to something.  If the values are not comparable,
    // returns negative if the first argument is “less” than the second, zero
    // if they are “equal”, and positive if the first argument is “greater”
    // returns 0, and an error of "Not Comparable" if not comparable
    Compare(interface{}) (int, error)
}

type Goroutree Uses

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

Goroutree is a tree set represented by a set of running goroutines, one per node in the tree. It is essentially an actor-based tree that holds machine-sized integers. The tree is unbalanced and does no rotations, so a series of inserts and deletes can make it very unbalanced. The tree is not going to be bombproof (because this is for a blog post) and probably has some obvious races.

func New Uses

func New() *Goroutree

New creates a new empty Goroutree

func (*Goroutree) Contains Uses

func (g *Goroutree) Contains(reschan chan bool, val Comparer)

Contains will tell if the set contains the given value. The channel passed will receive a true if the value does exist in the set and a false if not.

func (*Goroutree) Delete Uses

func (g *Goroutree) Delete(reschan chan bool, val Comparer)

Delete removes a value from the tree set if it exists. The channel passed will receive a true if the value did exist in the set and a false if not.

func (*Goroutree) Insert Uses

func (g *Goroutree) Insert(reschan chan bool, val Comparer)

Insert adds a new value into the set if it does not already exist. The channel passed will receive a true if the value was successfully inserted and a false if the value already existed.

func (*Goroutree) Print Uses

func (g *Goroutree) Print(reschan chan struct{}, w io.Writer)

Print will print out the tree. This is a blocking operation, so no other messages can be processed while printing. This is for debugging purposes only.

type Int Uses

type Int int

func (Int) Compare Uses

func (i Int) Compare(value interface{}) (int, error)

Package goroutree imports 4 packages (graph). Updated 2017-04-13. Refresh now. Tools for package owners.