slices

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

README

stdx/slices

Import path: github.com/InsideGallery/core/stdx/slices

Overview

stdx/slices contains generic slice batching and string shingling helpers.

Main APIs

  • BatchSlice[K any](size int, result []K) returns a channel that yields consecutive batches.
  • Shingle(text string, k int) returns a set.GenericDataSet[string] containing unique k-length shingles.

Usage

for batch := range coreslices.BatchSlice(2, []int{1, 2, 3, 4, 5}) {
	_ = batch
}

shingles := coreslices.Shingle("testing", 3)
_ = shingles

Notes

BatchSlice treats non-positive sizes as 1, starts a goroutine, and closes the channel after all batches are sent. Returned batches are slices of the original input. Shingle returns an empty set for empty text or non-positive k; when the text is shorter than k, it returns a set containing the whole text. Shingling uses byte indexes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchSlice

func BatchSlice[K any](size int, result []K) <-chan []K

func Shingle

func Shingle(text string, k int) set.GenericDataSet[string]

Types

This section is empty.

Jump to

Keyboard shortcuts

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