Documentation ¶
Index ¶
- Constants
- func Compare(a, b []byte) int
- func CompareString(a, b string) int
- func Count(b []byte, c byte) int
- func CountString(s string, c byte) int
- func Cutover(n int) int
- func Equal(a, b []byte) bool
- func HashStr[T string | []byte](sep T) (uint32, uint32)
- func HashStrBytes(sep []byte) (uint32, uint32)
- func HashStrRev[T string | []byte](sep T) (uint32, uint32)
- func HashStrRevBytes(sep []byte) (uint32, uint32)
- func Index(a, b []byte) int
- func IndexByte(b []byte, c byte) int
- func IndexByteString(s string, c byte) int
- func IndexRabinKarp[T string | []byte](s, sep T) int
- func IndexRabinKarpBytes(s, sep []byte) int
- func IndexString(str, sub string) int
- func LastIndexByte(s []byte, c byte) int
- func LastIndexByteString(s string, c byte) int
- func LastIndexRabinKarp[T string | []byte](s, sep T) int
- func MakeNoZero(n int) []byte
Constants ¶
const ( MaxLen = int(-1) >> 31 MaxBruteForce = MaxLen )
const PrimeRK = 16777619
PrimeRK is the prime base used in Rabin-Karp algorithm.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare two byte slices. Returns -1 if the first differing byte is lower in a, or 1 if the first differing byte is greater in b. If the byte slices are equal, returns 0. If the lengths are different and there are no differing bytes, compares based on length.
func CompareString ¶ added in v0.33.0
This function was copied from the Go 1.23 source tree (with runtime_cmpstring manually inlined).
func CountString ¶
Count the number of instances of a byte in a string.
func HashStr ¶ added in v0.14.1
HashStr returns the hash and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
This function was removed in Go 1.22.
func HashStrBytes ¶ added in v0.14.1
HashStrBytes returns the hash and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
This function was removed in Go 1.22.
func HashStrRev ¶ added in v0.14.1
HashStrRev returns the hash of the reverse of sep and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
Copied from the Go 1.22rc1 source tree.
func HashStrRevBytes ¶ added in v0.14.1
HashStrRevBytes returns the hash of the reverse of sep and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
This function was removed in Go 1.22.
func Index ¶
Index finds the base index of the first instance of the byte sequence b in a. If a does not contain b, this returns -1.
func IndexByte ¶
Index finds the index of the first instance of the specified byte in the slice. If the byte is not found, this returns -1.
func IndexByteString ¶
Index finds the index of the first instance of the specified byte in the string. If the byte is not found, this returns -1.
func IndexRabinKarp ¶ added in v0.14.1
IndexRabinKarp uses the Rabin-Karp search algorithm to return the index of the first occurrence of sep in s, or -1 if not present.
Copied from the Go 1.22rc1 source tree.
func IndexRabinKarpBytes ¶ added in v0.14.1
IndexRabinKarpBytes uses the Rabin-Karp search algorithm to return the index of the first occurrence of substr in s, or -1 if not present.
This function was removed in Go 1.22.
func IndexString ¶
Index finds the base index of the first instance of a substring in a string. If the substring is not found, this returns -1.
func LastIndexByte ¶ added in v0.31.0
Copied from the Go 1.22rc1 source tree.
func LastIndexByteString ¶ added in v0.31.0
Copied from the Go 1.22rc1 source tree.
func LastIndexRabinKarp ¶ added in v0.31.0
LastIndexRabinKarp uses the Rabin-Karp search algorithm to return the last index of the occurrence of sep in s, or -1 if not present.
Copied from the Go 1.22rc1 source tree.
func MakeNoZero ¶ added in v0.29.0
MakeNoZero makes a slice of length and capacity n without zeroing the bytes. It is the caller's responsibility to ensure uninitialized bytes do not leak to the end user.
Types ¶
This section is empty.