Documentation
¶
Overview ¶
Package hashset provides an implementation of a hashset.
Example ¶
package main
import (
"fmt"
g "github.com/zyedidia/generic"
"github.com/zyedidia/generic/hashset"
)
func main() {
set := hashset.New[string](3, g.Equals[string], g.HashString)
set.Put("foo")
set.Put("bar")
set.Put("baz")
fmt.Println(set.Has("foo"))
fmt.Println(set.Has("quux"))
set.Remove("foo")
fmt.Println(set.Has("foo"))
fmt.Println(set.Has("bar"))
set.Clear()
fmt.Println(set.Has("foo"))
fmt.Println(set.Has("bar"))
}
Output: true false false true false false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[K any] struct { // contains filtered or unexported fields }
Set implements a hashset, using the hashmap as the underlying storage.
func (*Set[K]) Clear ¶ added in v1.2.0
func (s *Set[K]) Clear()
Clear removes all elements from the set.
Click to show internal directories.
Click to hide internal directories.