mirror of
https://github.com/emirpasic/gods
synced 2024-11-08 13:10:26 +00:00
19 lines
598 B
Go
19 lines
598 B
Go
package examples
|
|
|
|
import "github.com/emirpasic/gods/sets/hashset"
|
|
|
|
func hashsetExample() {
|
|
set := hashset.New() // empty (keys are of type int)
|
|
set.Add(1) // 1
|
|
set.Add(2, 2, 3, 4, 5) // 3, 1, 2, 4, 5 (random order, duplicates ignored)
|
|
set.Remove(4) // 5, 3, 2, 1 (random order)
|
|
set.Remove(2, 3) // 1, 5 (random order)
|
|
set.Contains(1) // true
|
|
set.Contains(1, 5) // true
|
|
set.Contains(1, 6) // false
|
|
_ = set.Values() // []int{5,1} (random order)
|
|
set.Clear() // empty
|
|
set.Empty() // true
|
|
set.Size() // 0
|
|
}
|