xslice

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 6 Imported by: 4

README

xslice

References
  • xtesting*
Functions
Common
  • Shuffle(slice []interface{})
  • ShuffleNew(slice []interface{}) []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{}
  • ToSetWith(slice []interface{}, equaller Equaller) []interface{}
  • ToSet(s []interface{}) []interface{}
  • EqualWith(s1 []interface{}, s2 []interface{}, equaller Equaller) bool
  • Equal(s1 []interface{}, s2 []interface{}) bool
  • Range(min, max, step int) []int
  • ReverseRange(min, max, step int) []int
  • GenerateByIndex(index []int, f func(i int) interface{}) []interface{}
  • type SortSlice struct {}
  • NewSortSlice(s []interface{}, less func(i, j int) bool) SortSlice
  • ReverseSortSlice(s SortSlice) SortSlice
  • Sort(s []interface{}, less func(i, j int) bool)
  • StableSort(s []interface{}, less func(i, j int) bool)
Helper
  • 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 checks whether the value is in the slice without Equaller.

func ContainsWith

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

ContainsWith checks whether the value is in the slice with Equaller.

func Count

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

Count returns the count of value in the slice without Equaller.

func CountWith

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

CountWith returns the count of value in the slice with Equaller.

func Delete

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

Delete deletes a value from slice for n times without Equaller.

func DeleteAll

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

DeleteAll deletes a value from slice for all without Equaller.

func DeleteAllWith

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

DeleteAllWith deletes a value from slice for all with Equaller.

func DeleteWith

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

DeleteWith deletes a value from slice for n times with Equaller.

func Diff

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

Diff returns the difference of two slices without Equaller.

func DiffWith

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

DiffWith returns the difference of two slices with Equaller.

func Equal

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

Equal checks two slice is equal in elements without Equaller.

func EqualWith

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

EqualWith checks two slice is equal in elements with Equaller.

func ForEach

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

ForEach invokes function for each item in slice.

func GenerateByIndex added in v1.4.1

func GenerateByIndex(indies []int, fn func(i int) interface{}) []interface{}

GenerateByIndex generates a slice by indies and a generate function.

func GoForEach

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

GoForEach invokes a goroutine with a sync.WaitGroup, which invokes function for each item in slice.

func IndexOf

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

IndexOf returns the first index of value in the slice without Equaller.

func IndexOfWith

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

IndexOfWith returns the first index of value in the slice with Equaller.

func Intersection

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

Intersection returns the intersection of two slices without Equaller.

func IntersectionWith

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

IntersectionWith returns the intersection of two slices with Equaller.

func Its

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

Its means interface slice to slice. 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 maps a slice and return a new slice.

func Range added in v1.4.1

func Range(min, max, step int) []int

Range generates an integer slice from small to large with step.

func Reverse

func Reverse(slice []interface{})

Reverse reverses the slice directly.

func ReverseNew

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

ReverseNew reverse the old slice and return a new one.

func ReverseRange added in v1.4.1

func ReverseRange(min, max, step int) []int

ReverseRange generates an reverse integer slice from small to large with step.

func Shuffle

func Shuffle(slice []interface{})

Shuffle shuffles the slice directly.

func ShuffleNew

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

ShuffleNew shuffles the old slice and return a new one.

func Sort added in v1.4.1

func Sort(s []interface{}, less func(i, j int) bool)

func StableSort added in v1.4.1

func StableSort(s []interface{}, less func(i, j int) bool)

func Sti

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

Sti means slice to interface slice. Example:

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

func ToSet

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

ToSet removes the duplicate items in a slice as a set with Equaller.

func ToSetWith

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

ToSetWith removes the duplicate items in a slice as a set with Equaller.

func Union

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

Union returns the union of two slices without Equaller.

func UnionWith

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

UnionWith returns the union of two slices with Equaller.

Types

type Equaller

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

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

type SortSlice added in v1.4.1

type SortSlice struct {
	// contains filtered or unexported fields
}

func NewSortSlice added in v1.4.1

func NewSortSlice(s []interface{}, less func(i, j int) bool) SortSlice

func ReverseSortSlice added in v1.4.1

func ReverseSortSlice(s SortSlice) SortSlice

func (SortSlice) Len added in v1.4.1

func (s SortSlice) Len() int

func (SortSlice) Less added in v1.4.1

func (s SortSlice) Less(i, j int) bool

func (SortSlice) Swap added in v1.4.1

func (s SortSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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