slices

package
v1.0.42 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package slices 各种类型的切片.

包括 Runes, Strings, Int, Int64.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes added in v1.0.12

type Bytes []byte

Bytes 字节码切片.

Example
package main

import (
	"fmt"

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

func main() {
	s := slices.Bytes{'a', 'c'}

	fmt.Println(s[0])
	fmt.Println(s[1])
	fmt.Println(s.All('a', 'b'))
	fmt.Println(s.Any('a', 'b'))
	fmt.Println(s.Has('b'))
	fmt.Println(s.Index('c'))
	fmt.Println(s.Index('b'))
	fmt.Println(s)

}
Output:

97
99
false
true
false
1
-1
a, c

func (Bytes) All added in v1.0.12

func (x Bytes) All(elems ...byte) bool

All 全部包含.

func (Bytes) Any added in v1.0.12

func (x Bytes) Any(elems ...byte) bool

Any 任意包含.

func (*Bytes) Del added in v1.0.12

func (x *Bytes) Del(index int) Bytes

Del 根据序号删除.

func (Bytes) Has added in v1.0.12

func (x Bytes) Has(r byte) bool

Has 包含.

func (Bytes) Index added in v1.0.12

func (x Bytes) Index(r byte) int

Index 位置.

func (Bytes) Join added in v1.0.12

func (x Bytes) Join(sep string) string

Join 集合连接.

func (Bytes) Len added in v1.0.12

func (x Bytes) Len() int

func (Bytes) Less added in v1.0.12

func (x Bytes) Less(i, j int) bool

func (Bytes) String added in v1.0.12

func (x Bytes) String() string

String 转换成字符串.

func (Bytes) Swap added in v1.0.12

func (x Bytes) Swap(i, j int)

type Runes

type Runes []rune

Runes 切片.

Example
package main

import (
	"fmt"

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

func main() {
	rs := slices.Runes{'a', 'c'}

	fmt.Println(rs.All('a', 'b'))
	fmt.Println(rs.Any('a', 'b'))
	fmt.Println(rs.Has('b'))
	fmt.Println(rs.Index('c'))
	fmt.Println(rs.Index('b'))
	fmt.Println(rs)

}
Output:

false
true
false
1
-1
a, c

func (Runes) All

func (rs Runes) All(elems ...rune) bool

All 全部包含.

func (Runes) Any

func (rs Runes) Any(elems ...rune) bool

Any 任意包含.

func (Runes) Has

func (rs Runes) Has(r rune) bool

Has 包含.

func (Runes) Index

func (rs Runes) Index(r rune) int

Index 位置.

func (Runes) Join

func (rs Runes) Join(sep string) string

Join 连接.

func (Runes) String

func (rs Runes) String() string

String 转换成字符串.

type Strings

type Strings []string

Strings 切片.

Example
package main

import (
	"fmt"

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

func main() {
	s := slices.Strings{"a", "c"}

	fmt.Println(s[0])
	fmt.Println(s[1])
	fmt.Println(s.All("a", "b"))
	fmt.Println(s.Any("a", "b"))
	fmt.Println(s.Has("b"))
	fmt.Println(s.Index("c"))
	fmt.Println(s.Index("b"))
	fmt.Println(s)

}
Output:

a
c
false
true
false
1
-1
a, c

func (Strings) All

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

All 全部包含.

func (Strings) Any

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

Any 任意包含.

func (Strings) Has

func (s Strings) Has(r string) bool

Has 包含.

func (Strings) Index

func (s Strings) Index(r string) int

Index 位置.

func (Strings) String

func (s Strings) String() string

String 转换成字符串.

type Uint32s added in v1.0.7

type Uint32s []uint32

Uint32s 切片.

Example
package main

import (
	"fmt"

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

func main() {
	s := slices.Uint32s{3, 2}
	fmt.Println(s)

}
Output:

3, 2

func (Uint32s) All added in v1.0.7

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

All 全部包含.

func (Uint32s) Any added in v1.0.7

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

Any 任意包含.

func (*Uint32s) Del added in v1.0.7

func (x *Uint32s) Del(index int) Uint32s

Del 根据序号删除.

func (Uint32s) Has added in v1.0.7

func (x Uint32s) Has(r uint32) bool

Has 包含.

func (Uint32s) Index added in v1.0.7

func (x Uint32s) Index(r uint32) int

Index 位置.

func (Uint32s) Join added in v1.0.7

func (x Uint32s) Join(sep string) string

Join 集合连接.

func (Uint32s) Len added in v1.0.7

func (x Uint32s) Len() int

func (Uint32s) Less added in v1.0.7

func (x Uint32s) Less(i, j int) bool

func (Uint32s) String added in v1.0.7

func (x Uint32s) String() string

String 转换成字符串.

func (Uint32s) Swap added in v1.0.7

func (x Uint32s) Swap(i, j int)

Jump to

Keyboard shortcuts

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