slices

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 1 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 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 转换成字符串.

Jump to

Keyboard shortcuts

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