Documentation ¶
Overview ¶
Package mapset provides an implementation of a set using the built-in map.
Example ¶
package main import ( "fmt" "github.com/fufuok/utils/generic/mapset" ) func main() { set := mapset.New[string]() set.Put("foo") set.Put("bar") set.Put("baz") fmt.Println("foo", set.Has("foo")) fmt.Println("quux", set.Has("quux")) set.Remove("foo") fmt.Println("foo", set.Has("foo")) fmt.Println("bar", set.Has("bar")) set.Clear() fmt.Println("foo", set.Has("foo")) fmt.Println("bar", set.Has("bar")) }
Output: foo true quux false foo false bar true foo false bar false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[K comparable] struct { // contains filtered or unexported fields }
Set implements a hashset, using the hashmap as the underlying storage.
func Of ¶ added in v0.7.8
func Of[K comparable](vals ...K) Set[K]
Of returns a new hashset initialized with the given 'vals'
func (Set[K]) Clear ¶ added in v0.8.0
func (s Set[K]) Clear()
Clear removes all elements from the set.
Click to show internal directories.
Click to hide internal directories.