Documentation
¶
Index ¶
- type Int8Set
- func (s Int8Set) Add(elem int8) bool
- func (s Int8Set) AddList(elems ...int8) int
- func (s Int8Set) AddSet(set Int8Set)
- func (s Int8Set) Clear()
- func (s Int8Set) Contains(elem int8) bool
- func (s Int8Set) Copy() Int8Set
- func (s Int8Set) Equals(set interface{}) bool
- func (s Int8Set) Foreach(f func(v int8) bool)
- func (s Int8Set) IsEmpty() bool
- func (s Int8Set) Remove(elem int8) bool
- func (s Int8Set) RemoveSet(set Int8Set)
- func (s Int8Set) RetainSet(set Int8Set)
- func (s Int8Set) Size() int
- func (s Int8Set) String() string
- func (s Int8Set) ToList() []int8
- type Int16Set
- func (s Int16Set) Add(elem int16) bool
- func (s Int16Set) AddList(elems ...int16) int
- func (s Int16Set) AddSet(set Int16Set)
- func (s Int16Set) Clear()
- func (s Int16Set) Contains(elem int16) bool
- func (s Int16Set) Copy() Int16Set
- func (s Int16Set) Equals(set interface{}) bool
- func (s Int16Set) Foreach(f func(v int16) bool)
- func (s Int16Set) IsEmpty() bool
- func (s Int16Set) Remove(elem int16) bool
- func (s Int16Set) RemoveSet(set Int16Set)
- func (s Int16Set) RetainSet(set Int16Set)
- func (s Int16Set) Size() int
- func (s Int16Set) String() string
- func (s Int16Set) ToList() []int16
- type Int32Set
- func (s Int32Set) Add(elem int32) bool
- func (s Int32Set) AddList(elems ...int32) int
- func (s Int32Set) AddSet(set Int32Set)
- func (s Int32Set) Clear()
- func (s Int32Set) Contains(elem int32) bool
- func (s Int32Set) Copy() Int32Set
- func (s Int32Set) Equals(set interface{}) bool
- func (s Int32Set) Foreach(f func(v int32) bool)
- func (s Int32Set) IsEmpty() bool
- func (s Int32Set) Remove(elem int32) bool
- func (s Int32Set) RemoveSet(set Int32Set)
- func (s Int32Set) RetainSet(set Int32Set)
- func (s Int32Set) Size() int
- func (s Int32Set) String() string
- func (s Int32Set) ToList() []int32
- type Int64Set
- func (s Int64Set) Add(elem int64) bool
- func (s Int64Set) AddList(elems ...int64) int
- func (s Int64Set) AddSet(set Int64Set)
- func (s Int64Set) Clear()
- func (s Int64Set) Contains(elem int64) bool
- func (s Int64Set) Copy() Int64Set
- func (s Int64Set) Equals(set interface{}) bool
- func (s Int64Set) Foreach(f func(v int64) bool)
- func (s Int64Set) IsEmpty() bool
- func (s Int64Set) Remove(elem int64) bool
- func (s Int64Set) RemoveSet(set Int64Set)
- func (s Int64Set) RetainSet(set Int64Set)
- func (s Int64Set) Size() int
- func (s Int64Set) String() string
- func (s Int64Set) ToList() []int64
- type IntSet
- func (s IntSet) Add(elem int) bool
- func (s IntSet) AddList(elems ...int) int
- func (s IntSet) AddSet(set IntSet)
- func (s IntSet) Clear()
- func (s IntSet) Contains(elem int) bool
- func (s IntSet) Copy() IntSet
- func (s IntSet) Equals(set interface{}) bool
- func (s IntSet) Foreach(f func(v int) bool)
- func (s IntSet) IsEmpty() bool
- func (s IntSet) Remove(elem int) bool
- func (s IntSet) RemoveSet(set IntSet)
- func (s IntSet) RetainSet(set IntSet)
- func (s IntSet) Size() int
- func (s IntSet) String() string
- func (s IntSet) ToList() []int
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Int8Set ¶
type Int8Set map[int8]struct{}
Int8Set 定义int8集合
type Int16Set ¶
type Int16Set map[int16]struct{}
Int16Set 定义int16集合
type Int32Set ¶
type Int32Set map[int32]struct{}
Int32Set 定义int32集合
type Int64Set ¶
type Int64Set map[int64]struct{}
Int64Set 定义int64集合
type IntSet ¶
type IntSet map[int]struct{}
IntSet 定义int集合
Example ¶
package main
import (
"fmt"
"github.com/recallsong/go-utils/container/set/intset"
"github.com/recallsong/go-utils/container/slice/ints"
)
func main() {
set := intset.IntSet{}
// 向集合添加多个元素
set.AddList(1, 2, 3, 4, 5, 6, 5, 5, 5, 6, 6, 6)
// 向集合添加单个元素
set.Add(7)
// 排序并打印
fmt.Println(ints.Ints(set.ToList()).Sort())
// 集合运算
s1 := intset.IntSet{}
s1.AddList(1, 2, 3)
s2 := intset.IntSet{}
s2.AddList(3, 4, 5)
// 并集
s3 := s1.Copy()
s3.AddSet(s2)
fmt.Println(ints.Ints(s3.ToList()).Sort())
// 差集
s3 = s1.Copy()
s3.RemoveSet(s2)
fmt.Println(ints.Ints(s3.ToList()).Sort())
// 交集
s3 = s1.Copy()
s3.RetainSet(s2)
fmt.Println(ints.Ints(s3.ToList()).Sort())
}
Output: [1 2 3 4 5 6 7] [1 2 3 4 5] [1 2] [3]
Click to show internal directories.
Click to hide internal directories.