xslice

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MIT Imports: 4 Imported by: 4

README

xslice

Common Functions
  • Shuffle(slice []interface{}, source rand.Source)
  • ShuffleNew(slice []interface{}, source rand.Source) []interface{}
  • Reverse(slice []interface{}) []interface{}
  • ReverseNew(slice []interface{}) []interface{}
  • ForEach(slice []interface{}, each func(interface{}))
  • GoForEach(slice []interface{}, each func(interface{}))
  • Map(slice []interface{}, mapFunc func(interface{}) interface{}) []interface{}
  • IndexOfWith(slice []interface{}, value interface{}, equaller Equaller) int
  • IndexOf(slice []interface{}, value interface{}) int
  • ContainsWith(slice []interface{}, value interface{}, equaller Equaller) bool
  • Contains(slice []interface{}, value interface{}) bool
  • CountWith(slice []interface{}, value interface{}, equaller Equaller) int
  • Count(slice []interface{}, value interface{}) int
  • DeleteWith(slice []interface{}, value interface{}, n int, equaller Equaller) []interface{}
  • Delete(slice []interface{}, value interface{}, n int) []interface{}
  • DeleteAllWith(slice []interface{}, value interface{}, equaller Equaller) []interface{}
  • DeleteAll(slice []interface{}, value interface{}) []interface{}
  • DiffWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}
  • Diff(s1 []interface{}, s2 []interface{}) []interface{}
  • UnionWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}
  • Union(s1 []interface{}, s2 []interface{}) []interface{}
  • IntersectionWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}
  • Intersection(s1 []interface{}, s2 []interface{}) []interface{}
  • EqualWith(s1 []interface{}, s2 []interface{}, equaller Equaller) bool
  • Equal(s1 []interface{}, s2 []interface{}) bool
  • ToSetWith(slice []interface{}, equaller Equaller) []interface{}
  • ToSet(s []interface{}) []interface{}
Helper Functions
  • Sti(slice interface{}) []interface{}
  • Its(slice []interface{}, model interface{}) interface{}
  • ItsToString(slice []interface{}) []string
  • ItsOfString(slice []interface{}) []string
  • ItsOfByte(slice []interface{}) []byte
  • ItsOfRune(slice []interface{}) []rune
  • ItsOfInt(slice []interface{}) []int
  • ItsOfUint(slice []interface{}) []uint
  • ItsOfInt8(slice []interface{}) []int8
  • ItsOfUint8(slice []interface{}) []uint8
  • ItsOfInt16(slice []interface{}) []int16
  • ItsOfUint16(slice []interface{}) []uint16
  • ItsOfInt32(slice []interface{}) []int32
  • ItsOfUint32(slice []interface{}) []uint32
  • ItsOfInt64(slice []interface{}) []int64
  • ItsOfUint64(slice []interface{}) []uint64
  • ItsOfFloat32(slice []interface{}) []float32
  • ItsOfFloat64(slice []interface{}) []float64

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(slice []interface{}, value interface{}) bool

`Contains` with normal equal.

func ContainsWith

func ContainsWith(slice []interface{}, value interface{}, equaller Equaller) bool

`Contains` with equaller.

func Count

func Count(slice []interface{}, value interface{}) int

`Count` with equaller.

func CountWith

func CountWith(slice []interface{}, value interface{}, equaller Equaller) int

`Count` with equaller.

func Delete

func Delete(slice []interface{}, value interface{}, n int) []interface{}

`Delete` with normal equal.

func DeleteAll

func DeleteAll(slice []interface{}, value interface{}) []interface{}

`DeleteAll` with normal equal.

func DeleteAllWith

func DeleteAllWith(slice []interface{}, value interface{}, equaller Equaller) []interface{}

`DeleteAll` with equaller.

func DeleteWith

func DeleteWith(slice []interface{}, value interface{}, n int, equaller Equaller) []interface{}

`Delete` with equaller.

func Diff

func Diff(s1 []interface{}, s2 []interface{}) []interface{}

`Diff` with normal equal.

func DiffWith

func DiffWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}

`Diff` with equaller.

func Equal

func Equal(s1 []interface{}, s2 []interface{}) bool

`Equal` with normal equal.

func EqualWith

func EqualWith(s1 []interface{}, s2 []interface{}, equaller Equaller) bool

`Equal` with equaller.

func ForEach

func ForEach(slice []interface{}, each func(interface{}))

ForEach each item in slice.

func GoForEach

func GoForEach(slice []interface{}, each func(interface{}))

Use `go` and `WaitGroup` to ForEach the slice concurrently.

func IndexOf

func IndexOf(slice []interface{}, value interface{}) int

`IndexOf` with normal equal.

func IndexOfWith

func IndexOfWith(slice []interface{}, value interface{}, equaller Equaller) int

`IndexOf` with equaller.

func Intersection

func Intersection(s1 []interface{}, s2 []interface{}) []interface{}

`Intersection` with normal equal.

func IntersectionWith

func IntersectionWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}

`Intersection` with equaller.

func Its

func Its(slice []interface{}, model interface{}) interface{}

Example:

Its([]interface{}{0, 1}, 0).([]int) -> []int{0, 1}

func ItsOfByte

func ItsOfByte(slice []interface{}) []byte

func ItsOfFloat32

func ItsOfFloat32(slice []interface{}) []float32

func ItsOfFloat64

func ItsOfFloat64(slice []interface{}) []float64

func ItsOfInt

func ItsOfInt(slice []interface{}) []int

func ItsOfInt16

func ItsOfInt16(slice []interface{}) []int16

func ItsOfInt32

func ItsOfInt32(slice []interface{}) []int32

func ItsOfInt64

func ItsOfInt64(slice []interface{}) []int64

func ItsOfInt8

func ItsOfInt8(slice []interface{}) []int8

func ItsOfRune

func ItsOfRune(slice []interface{}) []rune

func ItsOfString

func ItsOfString(slice []interface{}) []string

func ItsOfUint

func ItsOfUint(slice []interface{}) []uint

func ItsOfUint16

func ItsOfUint16(slice []interface{}) []uint16

func ItsOfUint32

func ItsOfUint32(slice []interface{}) []uint32

func ItsOfUint64

func ItsOfUint64(slice []interface{}) []uint64

func ItsOfUint8

func ItsOfUint8(slice []interface{}) []uint8

func ItsToString

func ItsToString(slice []interface{}) []string

func Map

func Map(slice []interface{}, mapper func(interface{}) interface{}) []interface{}

`Map` a slice and return a new slice.

func Reverse

func Reverse(slice []interface{})

Reverse the slice directly.

func ReverseNew

func ReverseNew(slice []interface{}) []interface{}

Reverse the old slice and return a new one.

func Shuffle

func Shuffle(slice []interface{}, source rand.Source)

Shuffle the slice directly.

func ShuffleNew

func ShuffleNew(slice []interface{}, source rand.Source) []interface{}

Shuffle the old slice and return a new one.

func Sti

func Sti(slice interface{}) []interface{}

Example:

Sti([]int{0, 1}) -> []interface{}{0, 1}

func ToSet

func ToSet(s []interface{}) []interface{}

`ToSet` with normal equal.

func ToSetWith

func ToSetWith(slice []interface{}, equaller Equaller) []interface{}

`ToSet` with equaller.

func Union

func Union(s1 []interface{}, s2 []interface{}) []interface{}

`Union` with normal equal.

func UnionWith

func UnionWith(s1 []interface{}, s2 []interface{}, equaller Equaller) []interface{}

`Union` with equaller.

Types

type Equaller

type Equaller func(i, j interface{}) bool

An Equaller represents how two data equal, used in `XXXWith` methods.

Jump to

Keyboard shortcuts

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