Documentation ¶
Overview ¶
Package sliceutil implements set operations for specified data type
Currently types which are tested and supported are:
[]uint32 []int32 []string []float32 []uint64 []int64 []string []float64
Intersection, Union, Not , IsIn are the operations which are supported on slices
Index ¶
- func IntersectionByteSlices(s ...[][]byte) [][]byte
- func IntersectionInt64(s ...[]int64) []int64
- func IntersectionUint64(s ...[]uint64) []uint64
- func IsInInt64(a int64, b []int64) bool
- func IsInUint64(a uint64, b []uint64) bool
- func IsUint64Sorted(a []uint64) bool
- func NotInt64(a []int64, b []int64) []int64
- func NotUint64(a []uint64, b []uint64) []uint64
- func SetUint64(a []uint64) []uint64
- func SplitCommaSeparated(arr []string) []string
- func SplitOffset(listSize uint64, chunks uint64, index uint64) uint64
- func SubsetUint64(a []uint64, b []uint64) bool
- func UnionByteSlices(s ...[][]byte) [][]byte
- func UnionInt64(s ...[]int64) []int64
- func UnionUint64(s ...[]uint64) []uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntersectionByteSlices ¶
IntersectionByteSlices returns the common elements between sets of byte slices.
func IntersectionInt64 ¶
IntersectionInt64 of any number of int64 slices with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
func IntersectionUint64 ¶
IntersectionUint64 of any number of uint64 slices with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
func IsInUint64 ¶
IsInUint64 returns true if a is in b and False otherwise.
func IsUint64Sorted ¶
IsUint64Sorted verifies if a uint64 slice is sorted in ascending order.
func NotInt64 ¶
NotInt64 returns the int64 in slice a that are not in slice b with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
func NotUint64 ¶
NotUint64 returns the uint64 in slice a that are not in slice b with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
func SetUint64 ¶ added in v0.3.8
SetUint64 returns a slice with only unique values from the provided list of indices.
func SplitCommaSeparated ¶
SplitCommaSeparated values from the list. Example: []string{"a,b", "c,d"} becomes []string{"a", "b", "c", "d"}.
func SplitOffset ¶
SplitOffset returns the start index of a given list splits into chunks, it computes (listsize * index) / chunks.
Spec pseudocode definition: def get_split_offset(list_size: int, chunks: int, index: int) -> int:
""" Returns a value such that for a list L, chunk count k and index i, split(L, k)[i] == L[get_split_offset(len(L), k, i): get_split_offset(len(L), k, i+1)] """ return (list_size * index) // chunks
func SubsetUint64 ¶
SubsetUint64 returns true if the first array is completely contained in the second array with time complexity of approximately o(n).
func UnionByteSlices ¶
UnionByteSlices returns the common elements between sets of byte slices.
func UnionInt64 ¶
UnionInt64 of any number of int64 slices with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
func UnionUint64 ¶
UnionUint64 of any number of uint64 slices with time complexity of approximately O(n) leveraging a map to check for element existence off by a constant factor of underlying map efficiency.
Types ¶
This section is empty.