Skip to content
/ sortedset Public

Simple set implementation. Uses sorted slices and generics

License

Notifications You must be signed in to change notification settings

bsm/sortedset

Repository files navigation

Sorted Set

Go Reference Test License

Simple set implementation. Uses sorted slices and generics.

Documentation

Full documentation is available on go.dev.

Example

package main

import (
  "fmt"

  "github.com/bsm/sortedset"
)

func main() {
	// Create a new set
	set := sortedset.New[string]()

	// Seed with data
	set = set.Add("b")
	set = set.Add("a")
	set = set.Add("c", "a")
	fmt.Println(set.Slice()) // [a b c]

	// Check
	fmt.Println(set.Has("a")) // true
	fmt.Println(set.Has("d")) // false

	// Delete items
	set = set.Delete("a")
	set = set.Delete("d")
	fmt.Println(set.Slice()) // [b c]
}

About

Simple set implementation. Uses sorted slices and generics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published