intset

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 Int8Set

type Int8Set map[int8]struct{}

Int8Set 定义int8集合

func (Int8Set) Add

func (s Int8Set) Add(elem int8) bool

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

func (Int8Set) AddList

func (s Int8Set) AddList(elems ...int8) int

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

func (Int8Set) AddSet

func (s Int8Set) AddSet(set Int8Set)

AddSet 集合并集

func (Int8Set) Clear

func (s Int8Set) Clear()

Clear 清空集合元素

func (Int8Set) Contains

func (s Int8Set) Contains(elem int8) bool

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

func (Int8Set) Copy

func (s Int8Set) Copy() Int8Set

Copy 对集合进行浅拷贝

func (Int8Set) Equals

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

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

func (Int8Set) Foreach

func (s Int8Set) Foreach(f func(v int8) bool)

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

func (Int8Set) IsEmpty

func (s Int8Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Int8Set) Remove

func (s Int8Set) Remove(elem int8) bool

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

func (Int8Set) RemoveSet

func (s Int8Set) RemoveSet(set Int8Set)

removeSet 集合差集

func (Int8Set) RetainSet

func (s Int8Set) RetainSet(set Int8Set)

retainAll 集合交集

func (Int8Set) Size

func (s Int8Set) Size() int

Size 返回集合的大小

func (Int8Set) String

func (s Int8Set) String() string

String 将集合输出为字符串

func (Int8Set) ToList

func (s Int8Set) ToList() []int8

ToList 将集合转换为[]int8

type Int16Set

type Int16Set map[int16]struct{}

Int16Set 定义int16集合

func (Int16Set) Add

func (s Int16Set) Add(elem int16) bool

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

func (Int16Set) AddList

func (s Int16Set) AddList(elems ...int16) int

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

func (Int16Set) AddSet

func (s Int16Set) AddSet(set Int16Set)

AddSet 集合并集

func (Int16Set) Clear

func (s Int16Set) Clear()

Clear 清空集合元素

func (Int16Set) Contains

func (s Int16Set) Contains(elem int16) bool

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

func (Int16Set) Copy

func (s Int16Set) Copy() Int16Set

Copy 对集合进行浅拷贝

func (Int16Set) Equals

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

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

func (Int16Set) Foreach

func (s Int16Set) Foreach(f func(v int16) bool)

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

func (Int16Set) IsEmpty

func (s Int16Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Int16Set) Remove

func (s Int16Set) Remove(elem int16) bool

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

func (Int16Set) RemoveSet

func (s Int16Set) RemoveSet(set Int16Set)

removeSet 集合差集

func (Int16Set) RetainSet

func (s Int16Set) RetainSet(set Int16Set)

retainAll 集合交集

func (Int16Set) Size

func (s Int16Set) Size() int

Size 返回集合的大小

func (Int16Set) String

func (s Int16Set) String() string

String 将集合输出为字符串

func (Int16Set) ToList

func (s Int16Set) ToList() []int16

ToList 将集合转换为[]int16

type Int32Set

type Int32Set map[int32]struct{}

Int32Set 定义int32集合

func (Int32Set) Add

func (s Int32Set) Add(elem int32) bool

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

func (Int32Set) AddList

func (s Int32Set) AddList(elems ...int32) int

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

func (Int32Set) AddSet

func (s Int32Set) AddSet(set Int32Set)

AddSet 集合并集

func (Int32Set) Clear

func (s Int32Set) Clear()

Clear 清空集合元素

func (Int32Set) Contains

func (s Int32Set) Contains(elem int32) bool

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

func (Int32Set) Copy

func (s Int32Set) Copy() Int32Set

Copy 对集合进行浅拷贝

func (Int32Set) Equals

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

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

func (Int32Set) Foreach

func (s Int32Set) Foreach(f func(v int32) bool)

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

func (Int32Set) IsEmpty

func (s Int32Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Int32Set) Remove

func (s Int32Set) Remove(elem int32) bool

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

func (Int32Set) RemoveSet

func (s Int32Set) RemoveSet(set Int32Set)

removeSet 集合差集

func (Int32Set) RetainSet

func (s Int32Set) RetainSet(set Int32Set)

retainAll 集合交集

func (Int32Set) Size

func (s Int32Set) Size() int

Size 返回集合的大小

func (Int32Set) String

func (s Int32Set) String() string

String 将集合输出为字符串

func (Int32Set) ToList

func (s Int32Set) ToList() []int32

ToList 将集合转换为[]int32

type Int64Set

type Int64Set map[int64]struct{}

Int64Set 定义int64集合

func (Int64Set) Add

func (s Int64Set) Add(elem int64) bool

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

func (Int64Set) AddList

func (s Int64Set) AddList(elems ...int64) int

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

func (Int64Set) AddSet

func (s Int64Set) AddSet(set Int64Set)

AddSet 集合并集

func (Int64Set) Clear

func (s Int64Set) Clear()

Clear 清空集合元素

func (Int64Set) Contains

func (s Int64Set) Contains(elem int64) bool

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

func (Int64Set) Copy

func (s Int64Set) Copy() Int64Set

Copy 对集合进行浅拷贝

func (Int64Set) Equals

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

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

func (Int64Set) Foreach

func (s Int64Set) Foreach(f func(v int64) bool)

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

func (Int64Set) IsEmpty

func (s Int64Set) IsEmpty() bool

IsEmpty 判断集合是否为空

func (Int64Set) Remove

func (s Int64Set) Remove(elem int64) bool

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

func (Int64Set) RemoveSet

func (s Int64Set) RemoveSet(set Int64Set)

removeSet 集合差集

func (Int64Set) RetainSet

func (s Int64Set) RetainSet(set Int64Set)

retainAll 集合交集

func (Int64Set) Size

func (s Int64Set) Size() int

Size 返回集合的大小

func (Int64Set) String

func (s Int64Set) String() string

String 将集合输出为字符串

func (Int64Set) ToList

func (s Int64Set) ToList() []int64

ToList 将集合转换为[]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]

func (IntSet) Add

func (s IntSet) Add(elem int) bool

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

func (IntSet) AddList

func (s IntSet) AddList(elems ...int) int

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

func (IntSet) AddSet

func (s IntSet) AddSet(set IntSet)

AddSet 集合并集

func (IntSet) Clear

func (s IntSet) Clear()

Clear 清空集合元素

func (IntSet) Contains

func (s IntSet) Contains(elem int) bool

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

func (IntSet) Copy

func (s IntSet) Copy() IntSet

Copy 对集合进行浅拷贝

func (IntSet) Equals

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

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

func (IntSet) Foreach

func (s IntSet) Foreach(f func(v int) bool)

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

func (IntSet) IsEmpty

func (s IntSet) IsEmpty() bool

IsEmpty 判断集合是否为空

func (IntSet) Remove

func (s IntSet) Remove(elem int) bool

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

func (IntSet) RemoveSet

func (s IntSet) RemoveSet(set IntSet)

removeSet 集合差集

func (IntSet) RetainSet

func (s IntSet) RetainSet(set IntSet)

retainAll 集合交集

func (IntSet) Size

func (s IntSet) Size() int

Size 返回集合的大小

func (IntSet) String

func (s IntSet) String() string

String 将集合输出为字符串

func (IntSet) ToList

func (s IntSet) ToList() []int

ToList 将集合转换为[]int

Jump to

Keyboard shortcuts

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