sets

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sets 多种set.

包括 Int64s, Strings.

Index

Examples

Constants

This section is empty.

Variables

View Source
var None struct{} // nolint: gochecknoglobals

None 无值.

Functions

This section is empty.

Types

type Int64s added in v1.0.12

type Int64s map[int64]struct{}

Int64s int64 set.

Example
package main

import (
	"fmt"

	"gitee.com/xuender/oils/sets"
)

func main() {
	set := sets.NewInt64s(1, 2, 2)

	set.Add(3)

	fmt.Println(len(set))
	fmt.Println(set.Any(7, 2))
	fmt.Println(set.All(7, 2))
	fmt.Println(set.Has(3))

	set.Del(1)

	fmt.Println(len(set))
	fmt.Println(set)

}
Output:

3
true
false
true
2
2, 3

func NewInt64s added in v1.0.12

func NewInt64s(elems ...int64) Int64s

NewInt64s 新建字符串set.

func (Int64s) Add added in v1.0.12

func (set Int64s) Add(elems ...int64) Int64s

Add 增加字符串.

func (Int64s) All added in v1.0.12

func (set Int64s) All(elems ...int64) bool

All 包含全部.

func (Int64s) Any added in v1.0.12

func (set Int64s) Any(elems ...int64) bool

Any 包含任意个.

func (Int64s) Del added in v1.0.12

func (set Int64s) Del(elems ...int64) Int64s

Del 删除.

func (Int64s) Has added in v1.0.12

func (set Int64s) Has(s int64) bool

Has 包含.

func (Int64s) Join added in v1.0.12

func (set Int64s) Join(sep string) string

Join 集合连接.

func (Int64s) Slice added in v1.0.12

func (set Int64s) Slice() []int64

Slice 转换切片.

func (Int64s) String added in v1.0.12

func (set Int64s) String() string

String 字符串.

type Strings

type Strings map[string]struct{}

Strings 字符串set.

Example
package main

import (
	"fmt"

	"gitee.com/xuender/oils/sets"
)

func main() {
	set := sets.NewStrings("1", "2", "2")

	set.Add("3")

	fmt.Println(len(set))
	fmt.Println(set.Any("7", "2"))
	fmt.Println(set.All("7", "2"))

	set.Del("1")

	fmt.Println(len(set))

}
Output:

3
true
false
2

func NewStrings

func NewStrings(elems ...string) Strings

NewStrings 新建字符串set.

func (Strings) Add

func (set Strings) Add(elems ...string) Strings

Add 增加字符串.

func (Strings) AddStrings added in v1.0.31

func (set Strings) AddStrings(elems ...Strings) Strings

AddStrings 增加字符串set.

func (Strings) All

func (set Strings) All(elems ...string) bool

All 包含全部.

func (Strings) AllStrings added in v1.0.33

func (set Strings) AllStrings(elems ...Strings) bool

AllStrings 全部包含.

func (Strings) Any

func (set Strings) Any(elems ...string) bool

Any 包含任意个.

func (Strings) AnyStrings added in v1.0.33

func (set Strings) AnyStrings(elems ...Strings) bool

AnyStrings 包含任意.

func (Strings) Del

func (set Strings) Del(elems ...string) Strings

Del 删除.

func (Strings) DelStrings added in v1.0.31

func (set Strings) DelStrings(elems ...Strings) Strings

DelStrings 删除字符串set.

func (Strings) Has

func (set Strings) Has(s string) bool

Has 包含.

func (Strings) Join

func (set Strings) Join(sep string) string

Join 集合连接.

func (Strings) Slice

func (set Strings) Slice() []string

Slice 转换切片.

func (Strings) String

func (set Strings) String() string

String 字符串.

type Uint32s added in v1.0.32

type Uint32s map[uint32]struct{}

Uint32s uint32 set.

Example
package main

import (
	"fmt"

	"gitee.com/xuender/oils/sets"
)

func main() {
	set := sets.NewUint32s(1, 2, 2)

	set.Add(3)

	fmt.Println(len(set))
	fmt.Println(set.Any(7, 2))
	fmt.Println(set.All(7, 2))

	set.Del(1)

	fmt.Println(len(set))

}
Output:

3
true
false
2

func NewUint32s added in v1.0.32

func NewUint32s(elems ...uint32) Uint32s

NewUint32s 新建字符串set.

func (Uint32s) Add added in v1.0.32

func (set Uint32s) Add(elems ...uint32) Uint32s

Add 增加字符串.

func (Uint32s) AddUint32s added in v1.0.32

func (set Uint32s) AddUint32s(elems ...Uint32s) Uint32s

AddUint32s 增加字符串set.

func (Uint32s) All added in v1.0.32

func (set Uint32s) All(elems ...uint32) bool

All 包含全部.

func (Uint32s) Any added in v1.0.32

func (set Uint32s) Any(elems ...uint32) bool

Any 包含任意个.

func (Uint32s) Del added in v1.0.32

func (set Uint32s) Del(elems ...uint32) Uint32s

Del 删除.

func (Uint32s) DelUint32s added in v1.0.32

func (set Uint32s) DelUint32s(elems ...Uint32s) Uint32s

DelUint32s 删除uint32 set.

func (Uint32s) Has added in v1.0.32

func (set Uint32s) Has(i uint32) bool

Has 包含.

func (Uint32s) Join added in v1.0.32

func (set Uint32s) Join(sep string) string

Join 集合连接.

func (Uint32s) Slice added in v1.0.32

func (set Uint32s) Slice() []uint32

Slice 转换切片.

func (Uint32s) String added in v1.0.32

func (set Uint32s) String() string

String 字符串.

Jump to

Keyboard shortcuts

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