uintset

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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集合

func (Uint8Set) Add

func (s Uint8Set) Add(elem uint8) bool

Add 向集合添加元素,如果已存在,则返回false, 否则返回true

func (Uint8Set) AddList

func (s Uint8Set) AddList(elems ...uint8) int

AddList 向集合中添加一组元素,自动过滤重复元素,返回实际添加的元素数量

func (Uint8Set) AddSet

func (s Uint8Set) AddSet(set Uint8Set)

AddSet 集合并集

func (Uint8Set) Clear

func (s Uint8Set) Clear()

Clear 清空集合元素

func (Uint8Set) Contains

func (s Uint8Set) Contains(elem uint8) bool

Contains 判断集合是否包含该元素

func (Uint8Set) Copy

func (s Uint8Set) Copy() Uint8Set

Copy 对集合进行浅拷贝

func (Uint8Set) Equals

func (s Uint8Set) Equals(set interface{}) bool

Equals 对两个集合进行深度比较,返回是否相等

func (Uint8Set) Foreach

func (s Uint8Set) Foreach(f func(v uint8) bool)

Foreach 遍历集合,如果f返回 false ,则终止遍历

func (Uint8Set) IsEmpty

func (s Uint8Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Uint8Set) Remove

func (s Uint8Set) Remove(elem uint8) bool

Remove 从集合中删除元素,如果不存在,则返回false, 否则返回true

func (Uint8Set) RemoveSet

func (s Uint8Set) RemoveSet(set Uint8Set)

removeSet 集合差集

func (Uint8Set) RetainSet

func (s Uint8Set) RetainSet(set Uint8Set)

retainAll 集合交集

func (Uint8Set) Size

func (s Uint8Set) Size() int

Size 返回集合的大小

func (Uint8Set) String

func (s Uint8Set) String() string

String 将集合输出为字符串

func (Uint8Set) ToList

func (s Uint8Set) ToList() []uint8

ToList 将集合转换为[]uint8

type Uint16Set

type Uint16Set map[uint16]struct{}

Uint16Set 定义uint16集合

func (Uint16Set) Add

func (s Uint16Set) Add(elem uint16) bool

Add 向集合添加元素,如果已存在,则返回false, 否则返回true

func (Uint16Set) AddList

func (s Uint16Set) AddList(elems ...uint16) int

AddList 向集合中添加一组元素,自动过滤重复元素,返回实际添加的元素数量

func (Uint16Set) AddSet

func (s Uint16Set) AddSet(set Uint16Set)

AddSet 集合并集

func (Uint16Set) Clear

func (s Uint16Set) Clear()

Clear 清空集合元素

func (Uint16Set) Contains

func (s Uint16Set) Contains(elem uint16) bool

Contains 判断集合是否包含该元素

func (Uint16Set) Copy

func (s Uint16Set) Copy() Uint16Set

Copy 对集合进行浅拷贝

func (Uint16Set) Equals

func (s Uint16Set) Equals(set interface{}) bool

Equals 对两个集合进行深度比较,返回是否相等

func (Uint16Set) Foreach

func (s Uint16Set) Foreach(f func(v uint16) bool)

Foreach 遍历集合,如果f返回 false ,则终止遍历

func (Uint16Set) IsEmpty

func (s Uint16Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Uint16Set) Remove

func (s Uint16Set) Remove(elem uint16) bool

Remove 从集合中删除元素,如果不存在,则返回false, 否则返回true

func (Uint16Set) RemoveSet

func (s Uint16Set) RemoveSet(set Uint16Set)

removeSet 集合差集

func (Uint16Set) RetainSet

func (s Uint16Set) RetainSet(set Uint16Set)

retainAll 集合交集

func (Uint16Set) Size

func (s Uint16Set) Size() int

Size 返回集合的大小

func (Uint16Set) String

func (s Uint16Set) String() string

String 将集合输出为字符串

func (Uint16Set) ToList

func (s Uint16Set) ToList() []uint16

ToList 将集合转换为[]uint16

type Uint32Set

type Uint32Set map[uint32]struct{}

Uint32Set 定义uint32集合

func (Uint32Set) Add

func (s Uint32Set) Add(elem uint32) bool

Add 向集合添加元素,如果已存在,则返回false, 否则返回true

func (Uint32Set) AddList

func (s Uint32Set) AddList(elems ...uint32) int

AddList 向集合中添加一组元素,自动过滤重复元素,返回实际添加的元素数量

func (Uint32Set) AddSet

func (s Uint32Set) AddSet(set Uint32Set)

AddSet 集合并集

func (Uint32Set) Clear

func (s Uint32Set) Clear()

Clear 清空集合元素

func (Uint32Set) Contains

func (s Uint32Set) Contains(elem uint32) bool

Contains 判断集合是否包含该元素

func (Uint32Set) Copy

func (s Uint32Set) Copy() Uint32Set

Copy 对集合进行浅拷贝

func (Uint32Set) Equals

func (s Uint32Set) Equals(set interface{}) bool

Equals 对两个集合进行深度比较,返回是否相等

func (Uint32Set) Foreach

func (s Uint32Set) Foreach(f func(v uint32) bool)

Foreach 遍历集合,如果f返回 false ,则终止遍历

func (Uint32Set) IsEmpty

func (s Uint32Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Uint32Set) Remove

func (s Uint32Set) Remove(elem uint32) bool

Remove 从集合中删除元素,如果不存在,则返回false, 否则返回true

func (Uint32Set) RemoveSet

func (s Uint32Set) RemoveSet(set Uint32Set)

removeSet 集合差集

func (Uint32Set) RetainSet

func (s Uint32Set) RetainSet(set Uint32Set)

retainAll 集合交集

func (Uint32Set) Size

func (s Uint32Set) Size() int

Size 返回集合的大小

func (Uint32Set) String

func (s Uint32Set) String() string

String 将集合输出为字符串

func (Uint32Set) ToList

func (s Uint32Set) ToList() []uint32

ToList 将集合转换为[]uint32

type Uint64Set

type Uint64Set map[uint64]struct{}

Uint64Set 定义float32集合

func (Uint64Set) Add

func (s Uint64Set) Add(elem uint64) bool

Add 向集合添加元素,如果已存在,则返回false, 否则返回true

func (Uint64Set) AddList

func (s Uint64Set) AddList(elems ...uint64) int

AddList 向集合中添加一组元素,自动过滤重复元素,返回实际添加的元素数量

func (Uint64Set) AddSet

func (s Uint64Set) AddSet(set Uint64Set)

AddSet 集合并集

func (Uint64Set) Clear

func (s Uint64Set) Clear()

Clear 清空集合元素

func (Uint64Set) Contains

func (s Uint64Set) Contains(elem uint64) bool

Contains 判断集合是否包含该元素

func (Uint64Set) Copy

func (s Uint64Set) Copy() Uint64Set

Copy 对集合进行浅拷贝

func (Uint64Set) Equals

func (s Uint64Set) Equals(set interface{}) bool

Equals 对两个集合进行深度比较,返回是否相等

func (Uint64Set) Foreach

func (s Uint64Set) Foreach(f func(v uint64) bool)

Foreach 遍历集合,如果f返回 false ,则终止遍历

func (Uint64Set) IsEmpty

func (s Uint64Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Uint64Set) Remove

func (s Uint64Set) Remove(elem uint64) bool

Remove 从集合中删除元素,如果不存在,则返回false, 否则返回true

func (Uint64Set) RemoveSet

func (s Uint64Set) RemoveSet(set Uint64Set)

removeSet 集合差集

func (Uint64Set) RetainSet

func (s Uint64Set) RetainSet(set Uint64Set)

retainAll 集合交集

func (Uint64Set) Size

func (s Uint64Set) Size() int

Size 返回集合的大小

func (Uint64Set) String

func (s Uint64Set) String() string

String 将集合输出为字符串

func (Uint64Set) ToList

func (s Uint64Set) ToList() []uint64

ToList 将集合转换为[]uint64

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]

func (UintSet) Add

func (s UintSet) Add(elem uint) bool

Add 向集合添加元素,如果已存在,则返回false, 否则返回true

func (UintSet) AddList

func (s UintSet) AddList(elems ...uint) int

AddList 向集合中添加一组元素,自动过滤重复元素,返回实际添加的元素数量

func (UintSet) AddSet

func (s UintSet) AddSet(set UintSet)

AddSet 集合并集

func (UintSet) Clear

func (s UintSet) Clear()

Clear 清空集合元素

func (UintSet) Contains

func (s UintSet) Contains(elem uint) bool

Contains 判断集合是否包含该元素

func (UintSet) Copy

func (s UintSet) Copy() UintSet

Copy 对集合进行浅拷贝

func (UintSet) Equals

func (s UintSet) Equals(set interface{}) bool

Equals 对两个集合进行深度比较,返回是否相等

func (UintSet) Foreach

func (s UintSet) Foreach(f func(v uint) bool)

Foreach 遍历集合,如果f返回 false ,则终止遍历

func (UintSet) IsEmpty

func (s UintSet) IsEmpty() bool

IsEmpty 判断集合是否为空

func (UintSet) Remove

func (s UintSet) Remove(elem uint) bool

Remove 从集合中删除元素,如果不存在,则返回false, 否则返回true

func (UintSet) RemoveSet

func (s UintSet) RemoveSet(set UintSet)

removeSet 集合差集

func (UintSet) RetainSet

func (s UintSet) RetainSet(set UintSet)

retainAll 集合交集

func (UintSet) Size

func (s UintSet) Size() int

Size 返回集合的大小

func (UintSet) String

func (s UintSet) String() string

String 将集合输出为字符串

func (UintSet) ToList

func (s UintSet) ToList() []uint

ToList 将集合转换为[]uint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL