Documentation
¶
Overview ¶
The sliceutils package adds helper functions that deal with slices and walks.
Index ¶
- func DeleteCyclesInPlace(oldWalk []uint32, newWalk []uint32) []uint32
- func Difference[S ~[]E, E cmp.Ordered](slice1, slice2 S) S
- func Partition[S ~[]E, E cmp.Ordered](slice1, slice2 S) (removed, common, added S)
- func SortWalks(walks []models.RandomWalk) []models.RandomWalk
- func SplitSlice[S ~[]E, E cmp.Ordered](slice S, batchSize int) []S
- func TrimCycles(oldWalk []uint32, newWalk []uint32) []uint32
- func Unique[S ~[]E, E cmp.Ordered](slice S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteCyclesInPlace ¶
removes (in place) all elements from newWalk after the first occurrence of a cycle by checking against oldWalk. DeleteCyclesInPlace changes newWalk in the caller. If that's not wanted, use TrimCycles instead.
func Difference ¶
Difference() returns the difference between slice1 and slice2; in set notation:
- difference = slice1 - slice2
Time complexity O(n * logn + m * logm), where n and m are the lengths of the slices. This function is much faster than converting to sets for sizes (n, m) smaller than ~10^6.
func Partition ¶
Partition() returns removed, commond and added elements, using set notation:
removed = slice1 - slice2 common = slice1 ^ slice2 added = slice2 - slice1
Time complexity O(n * logn + m * logm), where n and m are the lengths of the slices. This function is much faster than converting to sets for sizes (n, m) smaller than ~10^6.
func SortWalks ¶
func SortWalks(walks []models.RandomWalk) []models.RandomWalk
SortWalks() sorts walks lexicographically.
func SplitSlice ¶
SplitSlice splits a slice into a slice of slices, each with a maximum size of batchSize
func TrimCycles ¶
returns a new slice up to the first occurrence of a cycle by checking against oldWalk. TrimCycles doesn't change newWalk in the caller. If that's wanted, use DeleteCyclesInPlace instead.
Types ¶
This section is empty.