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
- func Compare(a, b []byte) int
- func Count(b []byte, c byte) int
- func CountString(s string, c byte) int
- func Equal(a, b []byte) bool
- func HashStrRev(sep []byte) (uint32, uint32)
- func IndexByte(b []byte, c byte) int
- func IndexByteString(s string, c byte) int
- func IndexRabinKarp(s, sep []byte) int
- func LastIndexByte(s []byte, c byte) int
- func LastIndexByteString(s string, c byte) int
- func LastIndexRabinKarp(s, sep []byte) int
Constants ¶
const PrimeRK = 16777619
PrimeRK is the prime base used in Rabin-Karp algorithm.
Variables ¶
This section is empty.
Functions ¶
func CountString ¶
func Equal ¶
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 ¶
HashStrRev returns the hash of the reverse of sep and the appropriate multiplicative factor for use in Rabin-Karp algorithm.
func IndexByteString ¶
func IndexRabinKarp ¶
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 LastIndexByteString ¶
func LastIndexRabinKarp ¶
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.