Documentation
¶
Index ¶
- type Uint8Set
- func (s Uint8Set) Add(elem uint8) bool
- func (s Uint8Set) AddList(elems ...uint8) int
- func (s Uint8Set) AddSet(set Uint8Set)
- func (s Uint8Set) Clear()
- func (s Uint8Set) Contains(elem uint8) bool
- func (s Uint8Set) Copy() Uint8Set
- func (s Uint8Set) Equals(set interface{}) bool
- func (s Uint8Set) Foreach(f func(v uint8) bool)
- func (s Uint8Set) IsEmpty() bool
- func (s Uint8Set) Remove(elem uint8) bool
- func (s Uint8Set) RemoveSet(set Uint8Set)
- func (s Uint8Set) RetainSet(set Uint8Set)
- func (s Uint8Set) Size() int
- func (s Uint8Set) String() string
- func (s Uint8Set) ToList() []uint8
- type Uint16Set
- func (s Uint16Set) Add(elem uint16) bool
- func (s Uint16Set) AddList(elems ...uint16) int
- func (s Uint16Set) AddSet(set Uint16Set)
- func (s Uint16Set) Clear()
- func (s Uint16Set) Contains(elem uint16) bool
- func (s Uint16Set) Copy() Uint16Set
- func (s Uint16Set) Equals(set interface{}) bool
- func (s Uint16Set) Foreach(f func(v uint16) bool)
- func (s Uint16Set) IsEmpty() bool
- func (s Uint16Set) Remove(elem uint16) bool
- func (s Uint16Set) RemoveSet(set Uint16Set)
- func (s Uint16Set) RetainSet(set Uint16Set)
- func (s Uint16Set) Size() int
- func (s Uint16Set) String() string
- func (s Uint16Set) ToList() []uint16
- type Uint32Set
- func (s Uint32Set) Add(elem uint32) bool
- func (s Uint32Set) AddList(elems ...uint32) int
- func (s Uint32Set) AddSet(set Uint32Set)
- func (s Uint32Set) Clear()
- func (s Uint32Set) Contains(elem uint32) bool
- func (s Uint32Set) Copy() Uint32Set
- func (s Uint32Set) Equals(set interface{}) bool
- func (s Uint32Set) Foreach(f func(v uint32) bool)
- func (s Uint32Set) IsEmpty() bool
- func (s Uint32Set) Remove(elem uint32) bool
- func (s Uint32Set) RemoveSet(set Uint32Set)
- func (s Uint32Set) RetainSet(set Uint32Set)
- func (s Uint32Set) Size() int
- func (s Uint32Set) String() string
- func (s Uint32Set) ToList() []uint32
- type Uint64Set
- func (s Uint64Set) Add(elem uint64) bool
- func (s Uint64Set) AddList(elems ...uint64) int
- func (s Uint64Set) AddSet(set Uint64Set)
- func (s Uint64Set) Clear()
- func (s Uint64Set) Contains(elem uint64) bool
- func (s Uint64Set) Copy() Uint64Set
- func (s Uint64Set) Equals(set interface{}) bool
- func (s Uint64Set) Foreach(f func(v uint64) bool)
- func (s Uint64Set) IsEmpty() bool
- func (s Uint64Set) Remove(elem uint64) bool
- func (s Uint64Set) RemoveSet(set Uint64Set)
- func (s Uint64Set) RetainSet(set Uint64Set)
- func (s Uint64Set) Size() int
- func (s Uint64Set) String() string
- func (s Uint64Set) ToList() []uint64
- type UintSet
- func (s UintSet) Add(elem uint) bool
- func (s UintSet) AddList(elems ...uint) int
- func (s UintSet) AddSet(set UintSet)
- func (s UintSet) Clear()
- func (s UintSet) Contains(elem uint) bool
- func (s UintSet) Copy() UintSet
- func (s UintSet) Equals(set interface{}) bool
- func (s UintSet) Foreach(f func(v uint) bool)
- func (s UintSet) IsEmpty() bool
- func (s UintSet) Remove(elem uint) bool
- func (s UintSet) RemoveSet(set UintSet)
- func (s UintSet) RetainSet(set UintSet)
- func (s UintSet) Size() int
- func (s UintSet) String() string
- func (s UintSet) ToList() []uint
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Uint8Set ¶
type Uint8Set map[uint8]struct{}
Uint8Set 定义uint8集合
type Uint16Set ¶
type Uint16Set map[uint16]struct{}
Uint16Set 定义uint16集合
type Uint32Set ¶
type Uint32Set map[uint32]struct{}
Uint32Set 定义uint32集合
type Uint64Set ¶
type Uint64Set map[uint64]struct{}
Uint64Set 定义float32集合
type UintSet ¶
type UintSet map[uint]struct{}
UintSet 定义uint集合
Example ¶
package main
import (
"fmt"
"github.com/recallsong/go-utils/container/set/uintset"
"github.com/recallsong/go-utils/container/slice/uints"
)
func main() {
set := uintset.UintSet{}
// 向集合添加多个元素
set.AddList(1, 2, 3, 4, 5, 6, 5, 5, 5, 6, 6, 6)
// 向集合添加单个元素
set.Add(7)
// 排序并打印
fmt.Println(uints.Uints(set.ToList()).Sort())
// 集合运算
s1 := uintset.UintSet{}
s1.AddList(1, 2, 3)
s2 := uintset.UintSet{}
s2.AddList(3, 4, 5)
// 并集
s3 := s1.Copy()
s3.AddSet(s2)
fmt.Println(uints.Uints(s3.ToList()).Sort())
// 差集
s3 = s1.Copy()
s3.RemoveSet(s2)
fmt.Println(uints.Uints(s3.ToList()).Sort())
// 交集
s3 = s1.Copy()
s3.RetainSet(s2)
fmt.Println(uints.Uints(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.