Skip to content
/ sortb Public

Sortb, a Go package, provides a data structure to store sorted generic values using a balanced binary search tree.

License

Notifications You must be signed in to change notification settings

aryszka/sortb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc Go Report Card Coverage

sortb

Sortb, a Go package, provides a data structure to store sorted generic values using a balanced binary search tree.

Documentation: https://godoc.org/github.com/aryszka/sortb

Example:

type intt int

func (i intt) Less(j sortb.Value) bool  { return i < j.(intt) }
func (i intt) Equal(j sortb.Value) bool { return i == j.(intt) }

t := new(sortb.Tree)
for _, i := range []intt{-2, 5, 3, 0, 3, -1} {
	t.Insert(i)
}

iter := t.Iterate(nil)
for {
	v, ok := iter.Next()
	if !ok {
		break
	}

	fmt.Println(v)
}

Features:

  • independent comparison and equality of stored objects
  • basic operations: insert, find, delete, iterate
  • reverse iterate
  • iterate from an arbitrary start value
  • next/prev from an arbitrary value

About

Sortb, a Go package, provides a data structure to store sorted generic values using a balanced binary search tree.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages