mirror of
https://github.com/emirpasic/gods
synced 2024-11-06 15:20:25 +00:00
19 lines
739 B
Go
19 lines
739 B
Go
package examples
|
|
|
|
import "github.com/emirpasic/gods/sets/treeset"
|
|
|
|
func treesetExample() {
|
|
set := treeset.NewWithIntComparator() // empty
|
|
set.Add(1) // 1
|
|
set.Add(2, 2, 3, 4, 5) // 1, 2, 3, 4, 5 (in order, duplicates ignored)
|
|
set.Remove(4) // 1, 2, 3, 5 (in order)
|
|
set.Remove(2, 3) // 1, 5 (in order)
|
|
set.Contains(1) // true
|
|
set.Contains(1, 5) // true
|
|
set.Contains(1, 6) // false
|
|
_ = set.Values() // []int{1,5} (in order)
|
|
set.Clear() // empty
|
|
set.Empty() // true
|
|
set.Size() // 0
|
|
}
|