bytealg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package bytealg implements core byte algorithms. It's only meant for use by packages in the standard library. Others should use the bytes package instead.

Based on the internal/bytealg package.

Index

Constants

View Source
const PrimeRK = 16777619

PrimeRK is the prime base used in Rabin-Karp algorithm.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b []byte) int

func Count

func Count(b []byte, c byte) int

func CountString

func CountString(s string, c byte) int

func Equal

func Equal(a, b []byte) bool

Equal reports whether a and b are the same length and contain the same bytes. A nil argument is equivalent to an empty slice.

Equal is equivalent to bytes.Equal. It is provided here for convenience, because some packages cannot depend on bytes.

func HashStrRev

func HashStrRev(sep []byte) (uint32, uint32)

HashStrRev returns the hash of the reverse of sep and the appropriate multiplicative factor for use in Rabin-Karp algorithm.

func IndexByte

func IndexByte(b []byte, c byte) int

func IndexByteString

func IndexByteString(s string, c byte) int

func IndexRabinKarp

func IndexRabinKarp(s, sep []byte) int

IndexRabinKarp uses the Rabin-Karp search algorithm to return the index of the first occurrence of sep in s, or -1 if not present.

func LastIndexByte

func LastIndexByte(s []byte, c byte) int

func LastIndexByteString

func LastIndexByteString(s string, c byte) int

func LastIndexRabinKarp

func LastIndexRabinKarp(s, sep []byte) int

LastIndexRabinKarp uses the Rabin-Karp search algorithm to return the last index of the occurrence of sep in s, or -1 if not present.

Types

This section is empty.

Jump to

Keyboard shortcuts

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