bytealg

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLen        = int(-1) >> 31
	MaxBruteForce = MaxLen
)
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

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 Count

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

Count the number of instances of a byte in a slice.

func CountString

func CountString(s string, c byte) int

Count the number of instances of a byte in a string.

func Cutover

func Cutover(n int) int

Cutover is not reachable in TinyGo, but must exist as it is referenced.

func Equal

func Equal(a, b []byte) bool

Equal checks if two byte slices are equal. It is equivalent to bytes.Equal.

func HashStr added in v0.14.1

func HashStr(sep string) (uint32, uint32)

HashStr returns the hash and the appropriate multiplicative factor for use in Rabin-Karp algorithm.

func HashStrBytes added in v0.14.1

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

HashStrBytes returns the hash and the appropriate multiplicative factor for use in Rabin-Karp algorithm.

func HashStrRev added in v0.14.1

func HashStrRev(sep string) (uint32, uint32)

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

func HashStrRevBytes added in v0.14.1

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

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

func Index

func Index(a, b []byte) int

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

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

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

func IndexByteString(s string, c byte) int

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

func IndexRabinKarp(s, substr string) int

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

func IndexRabinKarpBytes added in v0.14.1

func IndexRabinKarpBytes(s, sep []byte) int

IndexRabinKarpBytes uses the Rabin-Karp search algorithm to return the index of the first occurence of substr in s, or -1 if not present.

func IndexString

func IndexString(str, sub string) int

Index finds the base index of the first instance of a substring in a string. If the substring is not found, this returns -1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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