set

package module
v0.0.0-...-cc58183 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2014 License: MIT Imports: 9 Imported by: 0

README

Set

Implements various sets and operations on them.

Caveats

Don't use this, I'm just benchmarking and comparing stuff for now.

Status

  • Build: Build Status
  • Coverage: >90%...

License

MIT, see ./LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GoMapIsMutable  MutableSet = NewGoMap(0)
	GoMapIsListable ListSet    = NewGoMap(0)
)

Guarantees the implementation of those interfaces

View Source
var (
	QuicktrieIsMutable  MutableSet = NewQuicktrie()
	QuicktrieIsListable ListSet    = NewQuicktrie()
)

Guarantees the implementation of those interfaces

Functions

func Difference

func Difference(a ListSet, b, out Set)

Difference between a and b. The result is stored in the out set. Everything that is in A but not in B will be the result.

func Intersect

func Intersect(a ListSet, b, out Set)

Intersect of the two list set, the result stored in the out set. Everything in both A and B is the result.

func Union

func Union(a, b ListSet, out Set)

Union of the two list set, the result stored in the out set. Everything in A or (inclusive) B is the result.

func XOR

func XOR(a, b ListSet, out Set)

XOR of the two list set, the result stored in the out set. Everything not in both A and B is the result.

Types

type GoMap

type GoMap map[string]struct{}

GoMap is a set of string implemented using Go maps.

func NewGoMap

func NewGoMap(n int) GoMap

NewGoMap creates a GoMap of capacity n.

func (GoMap) Add

func (m GoMap) Add(s string)

Add the key to the set.

func (GoMap) Contains

func (m GoMap) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (GoMap) Delete

func (m GoMap) Delete(s string)

Delete the element form this set.

func (GoMap) IsEmpty

func (m GoMap) IsEmpty() bool

IsEmpty tells if this set is empty.

func (GoMap) Keys

func (m GoMap) Keys() []string

Keys gives all the keys in this GoMap.

func (GoMap) Len

func (m GoMap) Len() int

Len is the length of this set.

type Hash128

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

Hash128 is a hash based set, using a 128 bits hasher.

func NewFarm128

func NewFarm128(n int, collidePanics bool) *Hash128

NewFarm128 is a Hash128 with farmhash for hasher.

func NewHashFunc128

func NewHashFunc128(n int, fh128 func(s []byte) (uint64, uint64), collidePanics bool) *Hash128

NewHashFunc128 creates a hash set using a hash128 hasher func.

func NewSpooky128

func NewSpooky128(n int, collidePanics bool) *Hash128

NewSpooky128 is a Hash128 with spooky hash for hasher.

func (*Hash128) Add

func (m *Hash128) Add(s string)

Add the key to the set.

func (*Hash128) Contains

func (m *Hash128) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (*Hash128) Delete

func (m *Hash128) Delete(s string)

Delete the element form this set.

func (*Hash128) IsEmpty

func (m *Hash128) IsEmpty() bool

IsEmpty tells if this set is empty.

func (*Hash128) Len

func (m *Hash128) Len() int

Len is the length of this set.

type Hash64

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

Hash64 is a hash based set, using a 64 bits hasher.

func NewFarm64

func NewFarm64(n int, collidePanics bool) *Hash64

NewFarm64 is a Hash64 with farmhash for hasher.

func NewHash64

func NewHash64(n int, h hash.Hash64, collidePanics bool) *Hash64

NewHash64 creates a hash set using a hash64 hasher.

func NewHashFunc64

func NewHashFunc64(n int, fh64 func(s []byte) uint64, collidePanics bool) *Hash64

NewHashFunc64 creates a hash set using a hash64 hasher func.

func NewSpooky64

func NewSpooky64(n int, collidePanics bool) *Hash64

NewSpooky64 is a Hash64 with spooky hash for hasher.

func (*Hash64) Add

func (m *Hash64) Add(s string)

Add the key to the set.

func (*Hash64) Contains

func (m *Hash64) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (*Hash64) Delete

func (m *Hash64) Delete(s string)

Delete the element form this set.

func (*Hash64) IsEmpty

func (m *Hash64) IsEmpty() bool

IsEmpty tells if this set is empty.

func (*Hash64) Len

func (m *Hash64) Len() int

Len is the length of this set.

type HashSHA1

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

HashSHA1 is a hash based set, using SHA1 for hashing.

func NewHashSHA1

func NewHashSHA1(n int, collidePanics bool) *HashSHA1

NewHashSHA1 creates a hash set using SHA1.

func (*HashSHA1) Add

func (m *HashSHA1) Add(s string)

Add the key to the set.

func (*HashSHA1) Contains

func (m *HashSHA1) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (*HashSHA1) Delete

func (m *HashSHA1) Delete(s string)

Delete the element form this set.

func (*HashSHA1) IsEmpty

func (m *HashSHA1) IsEmpty() bool

IsEmpty tells if this set is empty.

func (*HashSHA1) Len

func (m *HashSHA1) Len() int

Len is the length of this set.

type ListSet

type ListSet interface {
	Set
	Keys() []string
}

ListSet is a Set that can return the its keys.

type MinimalAcyclicFSA

type MinimalAcyclicFSA struct {
}

type MutableSet

type MutableSet interface {
	Set
	Delete(string)
}

MutableSet is a Set from which you can remove keys.

var (
	HashSHA1IsMutable MutableSet = NewHashSHA1(0, true)
)

type Quicktrie

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

Quicktrie is a set of string implemented using a sorted slice of strings.

func NewQuicktrie

func NewQuicktrie() *Quicktrie

NewQuicktrie creates a Quicktrie of capacity n.

func (*Quicktrie) Add

func (quick *Quicktrie) Add(s string)

Add the key to the set.

func (Quicktrie) Contains

func (quick Quicktrie) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (*Quicktrie) Delete

func (quick *Quicktrie) Delete(s string)

Delete the element form this set.

func (Quicktrie) IsEmpty

func (quick Quicktrie) IsEmpty() bool

IsEmpty tells if this set is empty.

func (Quicktrie) Keys

func (quick Quicktrie) Keys() (keys []string)

Keys gives all the keys in this Quicktrie.

func (Quicktrie) Len

func (quick Quicktrie) Len() int

Len is the length of this set.

type Set

type Set interface {
	Add(string)
	Contains(string) bool
	IsEmpty() bool
	Len() int
}

Set answers question of the type: is this string a member?

type TchapPatricia

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

TchapPatricia is a set of string implemented using a sorted slice of strings.

func NewTchapPatricia

func NewTchapPatricia() *TchapPatricia

NewTchapPatricia creates a TchapPatricia of capacity n.

func (*TchapPatricia) Add

func (pat *TchapPatricia) Add(s string)

Add the key to the set.

func (TchapPatricia) Contains

func (pat TchapPatricia) Contains(s string) bool

Contains tells if this key was in the set at least once.

func (*TchapPatricia) Delete

func (pat *TchapPatricia) Delete(s string)

Delete the element form this set.

func (TchapPatricia) IsEmpty

func (pat TchapPatricia) IsEmpty() bool

IsEmpty tells if this set is empty.

func (TchapPatricia) Keys

func (pat TchapPatricia) Keys() (keys []string)

Keys gives all the keys in this TchapPatricia.

func (TchapPatricia) Len

func (pat TchapPatricia) Len() (count int)

Len is the length of this set.

type TernarySet

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

TernarySet is a set specifically for string indexed keys.

func NewTernarySet

func NewTernarySet() *TernarySet

NewTernarySet creates a trie.

func (*TernarySet) Add

func (t *TernarySet) Add(key string)

Add the key to the set.

func (*TernarySet) Contains

func (t *TernarySet) Contains(key string) bool

Contains tells if key exists.

func (*TernarySet) DotGraph

func (t *TernarySet) DotGraph(out io.Writer, name string)

DotGraph prints the trie in DOT format.

func (*TernarySet) IsEmpty

func (t *TernarySet) IsEmpty() bool

IsEmpty tells if this set contains any elements.

func (*TernarySet) Keys

func (t *TernarySet) Keys() []string

Keys returns all the keys known to this trie

func (*TernarySet) Len

func (t *TernarySet) Len() int

Len returns the count of elements in this set.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL