sets

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: May 4, 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) All

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

All 包含全部.

func (Strings) Any

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

Any 包含任意个.

func (Strings) Del

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

Del 删除.

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 字符串.

Jump to

Keyboard shortcuts

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