sliceutil

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: GPL-3.0 Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntersectionByteSlices

func IntersectionByteSlices(s ...[][]byte) [][]byte

IntersectionByteSlices returns the common elements between sets of byte slices.

func IntersectionInt64

func IntersectionInt64(s ...[]int64) []int64

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

func IntersectionUint64(s ...[]uint64) []uint64

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 IsInInt64

func IsInInt64(a int64, b []int64) bool

IsInInt64 returns true if a is in b and False otherwise.

func IsInUint64

func IsInUint64(a uint64, b []uint64) bool

IsInUint64 returns true if a is in b and False otherwise.

func IsUint64Sorted

func IsUint64Sorted(a []uint64) bool

IsUint64Sorted verifies if a uint64 slice is sorted in ascending order.

func NotInt64

func NotInt64(a []int64, b []int64) []int64

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

func NotUint64(a []uint64, b []uint64) []uint64

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 SplitCommaSeparated

func SplitCommaSeparated(arr []string) []string

SplitCommaSeparated values from the list. Example: []string{"a,b", "c,d"} becomes []string{"a", "b", "c", "d"}.

func SplitOffset

func SplitOffset(listSize uint64, chunks uint64, index uint64) uint64

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

func SubsetUint64(a []uint64, b []uint64) bool

SubsetUint64 returns true if the first array is completely contained in the second array with time complexity of approximately o(n).

func UnionByteSlices

func UnionByteSlices(s ...[][]byte) [][]byte

UnionByteSlices returns the common elements between sets of byte slices.

func UnionInt64

func UnionInt64(s ...[]int64) []int64

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

func UnionUint64(s ...[]uint64) []uint64

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.

Jump to

Keyboard shortcuts

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