package bytealg

Import Path
	internal/bytealg (on go.dev)

Dependency Relation
	imports 2 packages, and imported by 16 packages


Package-Level Functions (total 17)
func Compare(a, b []byte) int
func Count(b []byte, c byte) int
Cutover reports the number of failures of IndexByte we should tolerate before switching over to Index. n is the number of bytes processed so far. See the bytes.Index implementation for details.
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.
Type Parameters: T: string | []byte HashStr returns the hash and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
Type Parameters: T: string | []byte HashStrRev returns the hash of the reverse of sep and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
Index returns the index of the first instance of b in a, or -1 if b is not present in a. Requires 2 <= len(b) <= MaxLen.
func IndexByte(b []byte, c byte) int
Type Parameters: T: string | []byte IndexRabinKarp uses the Rabin-Karp search algorithm to return the index of the first occurrence of sep in s, or -1 if not present.
IndexString returns the index of the first instance of b in a, or -1 if b is not present in a. Requires 2 <= len(b) <= MaxLen.
func LastIndexByte(s []byte, c byte) int
Type Parameters: T: string | []byte LastIndexRabinKarp uses the Rabin-Karp search algorithm to return the last index of the occurrence of sep in s, or -1 if not present.
MakeNoZero makes a slice of length n and capacity of at least n Bytes without zeroing the bytes (including the bytes between len and cap). It is the caller's responsibility to ensure uninitialized bytes do not leak to the end user.
Package-Level Variables (only one)
MaxLen is the maximum length of the string to be searched for (argument b) in Index. If MaxLen is not 0, make sure MaxLen >= 4.
Package-Level Constants (total 2)
const MaxBruteForce = 64
PrimeRK is the prime base used in Rabin-Karp algorithm.