slice

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package slice wraps up some common operations regarding to golang slice with different types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkInt64s added in v1.4.0

func ChunkInt64s(x []int64, chunkSize int) (chunks [][]int64)

ChunkInt64s chunks the slice by given chunk size

func ChunkInts added in v1.4.0

func ChunkInts(x []int, chunkSize int) (chunks [][]int)

ChunkInts chunks the slice by given chunk size

func ChunkStrings added in v1.4.0

func ChunkStrings(x []string, chunkSize int) (chunks [][]string)

ChunkStrings chunks the slice by given chunk size

func ChunkUInt64s added in v1.4.0

func ChunkUInt64s(x []uint64, chunkSize int) (chunks [][]uint64)

ChunkUInt64s chunks the slice by given chunk size

func ContainsInt

func ContainsInt(x []int, y int) bool

ContainsInt checks whether an int element is in an int slice

func ContainsInt64

func ContainsInt64(x []int64, y int64) bool

ContainsInt64 checks whether an int64 element is in an int64 slice

func ContainsString

func ContainsString(x []string, y string) bool

ContainsString checks whether a string element is in a string slice

func ContainsUInt64

func ContainsUInt64(x []uint64, y uint64) bool

ContainsUInt64 checks whether an uint64 element is in an uint64 slice

func CopyInt64s

func CopyInt64s(x []int64) []int64

CopyInt64s makes a new int64 slice that copies the content of the given int64 slice

func CopyInts

func CopyInts(x []int) []int

CopyInts makes a new int slice that copies the content of the given int slice

func CopyStrings

func CopyStrings(x []string) []string

CopyStrings makes a new string slice that copies the content of the given string slice

func CopyUInt64s

func CopyUInt64s(x []uint64) []uint64

CopyUInt64s makes a new uint64 slice that copies the content of the given uint64 slice

func CutInt64s

func CutInt64s(x []int64, i, j int) ([]int64, error)

CutInt64s cuts an int64 slice by removing the elements starts from i and ends at j-1

func CutInts

func CutInts(x []int, i, j int) ([]int, error)

CutInts cuts an int slice by removing the elements starts from i and ends at j-1

func CutStrings

func CutStrings(x []string, i, j int) ([]string, error)

CutStrings cuts a string slice by removing the elements starts from i and ends at j-1

func CutUInt64s

func CutUInt64s(x []uint64, i, j int) ([]uint64, error)

CutUInt64s cuts an uint64 slice by removing the elements starts from i and ends at j-1

func EqualsInt64s

func EqualsInt64s(x []int64, y []int64) bool

EqualsInt64s checks whether two int64 slice has the same elements

func EqualsInts

func EqualsInts(x []int, y []int) bool

EqualsInts checks whether two int slice has the same elements

func EqualsStrings

func EqualsStrings(x []string, y []string) bool

EqualsStrings checks whether two string slice has the same elements

func EqualsUInt64s

func EqualsUInt64s(x []uint64, y []uint64) bool

EqualsUInt64s checks whether two uint64 slice has the same elements

func FilterInt64s

func FilterInt64s(x []int64, filter func(int64) bool) []int64

FilterInt64s filters an int64 slice by the given filter function

func FilterInts

func FilterInts(x []int, filter func(int) bool) []int

FilterInts filters an int slice by the given filter function

func FilterStrings

func FilterStrings(x []string, filter func(string) bool) []string

FilterStrings filters a string slice by the given filter function

func FilterUInt64s

func FilterUInt64s(x []uint64, filter func(uint64) bool) []uint64

FilterUInt64s filters an uint64 slice by the given filter function

func IndexOfInt

func IndexOfInt(x []int, y int) int

IndexOfInt gets the index of an int element in an int slice

func IndexOfInt64

func IndexOfInt64(x []int64, y int64) int

IndexOfInt64 gets the index of an int64 element in an int64 slice

func IndexOfString

func IndexOfString(x []string, y string) int

IndexOfString gets the index of a string element in a string slice

func IndexOfUInt64

func IndexOfUInt64(x []uint64, y uint64) int

IndexOfUInt64 gets the index of an uint64 element in an uint64 slice

func InsertInt64At

func InsertInt64At(x []int64, y int64, index int) ([]int64, error)

InsertInt64At inserts an int64 value into a given int64 slice at given index

func InsertInt64sAt

func InsertInt64sAt(x []int64, y []int64, index int) ([]int64, error)

InsertInt64sAt inserts a int64 slice into a given int64 slice at given index

func InsertIntAt

func InsertIntAt(x []int, y int, index int) ([]int, error)

InsertIntAt inserts an int value into a given int slice at given index

func InsertIntsAt

func InsertIntsAt(x []int, y []int, index int) ([]int, error)

InsertIntsAt inserts a int slice into a given int slice at given index

func InsertStringAt

func InsertStringAt(x []string, y string, index int) ([]string, error)

InsertStringAt inserts a string value stringo a given string slice at given index

func InsertStringsAt

func InsertStringsAt(x []string, y []string, index int) ([]string, error)

InsertStringsAt inserts a string slice stringo a given string slice at given index

func InsertUInt64At

func InsertUInt64At(x []uint64, y uint64, index int) ([]uint64, error)

InsertUInt64At inserts an uint64 value into a given uint64 slice at given index

func InsertUInt64sAt

func InsertUInt64sAt(x []uint64, y []uint64, index int) ([]uint64, error)

InsertUInt64sAt inserts a uint64 slice into a given uint64 slice at given index

func MergeInt64s

func MergeInt64s(x []int64, y []int64, excludes ...int64) []int64

MergeInt64s merges two int64 slice with specific excluded values

func MergeInts

func MergeInts(x []int, y []int, excludes ...int) []int

MergeInts merges two int slice with specific excluded values

func MergeStrings

func MergeStrings(x []string, y []string, excludes ...string) []string

MergeStrings merges two string slice with specific excluded values

func MergeUInt64s

func MergeUInt64s(x []uint64, y []uint64, excludes ...uint64) []uint64

MergeUInt64s merges two uint64 slice with specific excluded values

func PopFirstInt

func PopFirstInt(x []int) (int, []int, error)

PopFirstInt pops the first value of an int slice

func PopFirstInt64

func PopFirstInt64(x []int64) (int64, []int64, error)

PopFirstInt64 pops the first value of an int64 slice

func PopFirstString

func PopFirstString(x []string) (string, []string, error)

PopFirstString pops the first value of a string slice

func PopFirstUInt64

func PopFirstUInt64(x []uint64) (uint64, []uint64, error)

PopFirstUInt64 pops the first value of an uint64 slice

func PopLastInt

func PopLastInt(x []int) (int, []int, error)

PopLastInt pops the last value of an int slice

func PopLastInt64

func PopLastInt64(x []int64) (int64, []int64, error)

PopLastInt64 pops the last value of an int64 slice

func PopLastString

func PopLastString(x []string) (string, []string, error)

PopLastString pops the last value of a string slice

func PopLastUInt64

func PopLastUInt64(x []uint64) (uint64, []uint64, error)

PopLastUInt64 pops the last value of an uint64 slice

func RemoveInt

func RemoveInt(x []int, y int) []int

RemoveInt removes an int from a given int slice by value

func RemoveInt64

func RemoveInt64(x []int64, y int64) []int64

RemoveInt64 removes an int64 from a given int64 slice by value

func RemoveInt64At

func RemoveInt64At(x []int64, index int) ([]int64, error)

RemoveInt64At removes an int64 from a given int64 slice by index

func RemoveIntAt

func RemoveIntAt(x []int, index int) ([]int, error)

RemoveIntAt removes an int from a given int slice by index

func RemoveString

func RemoveString(x []string, y string) []string

RemoveString removes a string from a given string slice by value

func RemoveStringAt

func RemoveStringAt(x []string, index int) ([]string, error)

RemoveStringAt removes a string from a given string slice by index

func RemoveUInt64

func RemoveUInt64(x []uint64, y uint64) []uint64

RemoveUInt64 removes an uint64 from a given uint64 slice by value

func RemoveUInt64At

func RemoveUInt64At(x []uint64, index int) ([]uint64, error)

RemoveUInt64At removes an uint64 from a given uint64 slice by index

func ReverseInt64s

func ReverseInt64s(x []int64) []int64

ReverseInt64s reverses an int64 slice

func ReverseInts

func ReverseInts(x []int) []int

ReverseInts reverses an int slice

func ReverseStrings

func ReverseStrings(x []string) []string

ReverseStrings reverses a string slice

func ReverseUInt64s

func ReverseUInt64s(x []uint64) []uint64

ReverseUInt64s reverses an uint64 slice

func ShuffleInt64s

func ShuffleInt64s(x []int64) []int64

ShuffleInt64s shuffles an int64 slice

func ShuffleInts

func ShuffleInts(x []int) []int

ShuffleInts shuffles an int slice

func ShuffleStrings

func ShuffleStrings(x []string) []string

ShuffleStrings shuffles a string slice

func ShuffleUInt64s

func ShuffleUInt64s(x []uint64) []uint64

ShuffleUInt64s shuffles an uint64 slice

func SumOfInt64s

func SumOfInt64s(x []int64) int64

SumOfInt64s find the sum of all items in int64 slice

func SumOfInts

func SumOfInts(x []int) int

SumOfInts find the sum of all items in int slice

func SumOfUInt64s

func SumOfUInt64s(x []uint64) uint64

SumOfUInt64s find the sum of all items in uint64 slice

func TransformInt64s

func TransformInt64s(target, current []int64) (add, remove []int64)

TransformInt64s helps figure out how to transform current to target slice by returning the ones to add and remove

func TransformInts

func TransformInts(target, current []int) (add, remove []int)

TransformInts helps figure out how to transform current to target slice by returning the ones to add and remove

func TransformStrings

func TransformStrings(target, current []string) (add, remove []string)

TransformStrings helps figure out how to transform current to target slice by returning the ones to add and remove

func TransformUInt64s

func TransformUInt64s(target, current []uint64) (add, remove []uint64)

TransformUInt64s helps figure out how to transform current to target slice by returning the ones to add and remove

func UniqueInt64s added in v1.0.2

func UniqueInt64s(x []int64) []int64

UniqueInt64s removes the duplicates from the int64 slice

func UniqueInts added in v1.0.2

func UniqueInts(x []int) []int

UniqueInts removes the duplicates from the int slice

func UniqueStrings

func UniqueStrings(x []string) []string

UniqueStrings removes the duplicates from the string slice

func UniqueUInt64s added in v1.0.2

func UniqueUInt64s(x []uint64) []uint64

UniqueUInt64s removes the duplicates from the uint64 slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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