bytealg

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 9 Imported by: 30

README

ByteAlg

Alloc-free replacements for packages bytes and strings.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSplit

func AppendSplit[T byteseq.Byteseq](buf []T, x, sep T, n int) []T

AppendSplit splits x to buf using sep as separator.

This function if an alloc-free replacement of bytes.Split() function.

func AppendSplitBytes added in v1.0.4

func AppendSplitBytes(buf [][]byte, p, sep []byte, n int) [][]byte

AppendSplitBytes splits p to buf using sep as separator.

func AppendSplitEntry added in v1.0.4

func AppendSplitEntry[T byteseq.Byteseq](buf []entry.Entry64, s, sep T, n int) []entry.Entry64

AppendSplitEntry splits x to buf using sep as separator.

buf contains entry.Entry64 records instead of substrings.

func AppendSplitEntryBytes added in v1.0.4

func AppendSplitEntryBytes(buf []entry.Entry64, p, sep []byte, n int) []entry.Entry64

AppendSplitEntryBytes splits p to buf using sep as separator.

func AppendSplitEntryString added in v1.0.4

func AppendSplitEntryString(buf []entry.Entry64, s, sep string, n int) []entry.Entry64

AppendSplitEntryString splits s to buf using sep as separator.

func AppendSplitString added in v1.0.4

func AppendSplitString(buf []string, s, sep string, n int) []string

AppendSplitString splits s to buf using sep as separator.

func Copy

func Copy[T byteseq.Byteseq](p T) T

Copy makes a copy of byte sequence.

func CopyBytes added in v1.0.7

func CopyBytes(p []byte) (r []byte)

CopyBytes makes a copy of byte slice.

func CopyString added in v1.0.7

func CopyString(s string) (r string)

CopyString makes a copy of string.

func EqualSet

func EqualSet[T byteseq.Byteseq](a, b []T) bool

EqualSet checks if two slices of bytes slices is equal.

func Grow

func Grow(p []byte, newLen int) []byte

Grow increases length of the byte array.

Two cases are possible: * byte array has enough space; * need to add extra space to the array.

func GrowDelta

func GrowDelta(p []byte, delta int) []byte

GrowDelta increases length of byte array to actual length + delta.

See Grow().

func HasByte added in v1.0.4

func HasByte[T byteseq.Q](x T, c byte) bool

HasByte checks if c is present in p.

func HasByteAt added in v1.0.4

func HasByteAt[T byteseq.Q](x T, c byte, at int) bool

HasByteAt checks if c is present in p (from position at).

func HasByteAtBytes added in v1.0.4

func HasByteAtBytes(p []byte, c byte, at int) bool

HasByteAtBytes checks if c is present in p (from position at).

func HasByteAtString added in v1.0.4

func HasByteAtString(s string, c byte, at int) bool

HasByteAtString checks if c is present in p (from position at).

func HasByteBytes added in v1.0.4

func HasByteBytes(p []byte, c byte) bool

HasByteBytes checks if c is present in p.

func HasByteLUR added in v1.0.2

func HasByteLUR(p []byte, b byte) bool

HasByteLUR checks if p contains b.

This function designed to use with the largest input.

func HasByteString added in v1.0.4

func HasByteString(s string, c byte) bool

HasByteString checks if c is present in p.

func IndexAnyAt

func IndexAnyAt[T byteseq.Q](x, sep T, at int) int

IndexAnyAt is equal to bytes.IndexAny() but doesn't consider occurrences of sep in p[:at].

func IndexAnyAtBytes added in v1.0.4

func IndexAnyAtBytes(p, sep []byte, at int) int

IndexAnyAtBytes is equal to bytes.IndexAny() but doesn't consider occurrences of sep in p[:at].

func IndexAnyAtString added in v1.0.4

func IndexAnyAtString(s, sep string, at int) int

IndexAnyAtString is equal to bytes.IndexAny() but doesn't consider occurrences of sep in p[:at].

func IndexAt

func IndexAt[T byteseq.Q](x, sep T, at int) int

IndexAt is equal to bytes.Index() but doesn't consider occurrences of sep in p[:at].

func IndexAtBytes added in v1.0.4

func IndexAtBytes(p, sep []byte, at int) int

IndexAtBytes is equal to bytes.Index() but doesn't consider occurrences of sep in p[:at].

func IndexAtString added in v1.0.4

func IndexAtString(s, sep string, at int) int

IndexAtString is equal to bytes.Index() but doesn't consider occurrences of sep in p[:at].

func IndexByteAt added in v1.0.4

func IndexByteAt[T byteseq.Q](x T, c byte, at int) int

IndexByteAt returns the index of the first instance of c in p (from position at), or -1 if c is not present in p.

func IndexByteAtBytes added in v1.0.4

func IndexByteAtBytes(p []byte, c byte, at int) int

IndexByteAtBytes returns the index of the first instance of c in p (from position at), or -1 if c is not present in p.

func IndexByteAtLUR added in v1.0.2

func IndexByteAtLUR(p []byte, b byte, at int) int

IndexByteAtLUR is a loop unrolling version of IndexAtBytes().

func IndexByteAtString added in v1.0.4

func IndexByteAtString(s string, c byte, at int) int

IndexByteAtString returns the index of the first instance of c in p (from position at), or -1 if c is not present in p.

func Map

func Map[T byteseq.Byteseq](mapping func(r rune) rune, x T) T

Map returns modified x with all its characters modified according to the mapping function.

See bytes.Map()/strings.Map() function for details.

func MapBytes added in v1.0.7

func MapBytes(mapping func(r rune) rune, p []byte) []byte

func MapString added in v1.0.7

func MapString(mapping func(r rune) rune, s string) string

func SkipBytesFmt4 added in v1.0.5

func SkipBytesFmt4(p []byte, offset int) (int, bool)

SkipBytesFmt4 moves offset to first non-fmt4 byte in bytes p. Returns new offset and EOF flag.

func SkipFmt4 added in v1.0.5

func SkipFmt4[T byteseq.Q](x T, offset int) (int, bool)

SkipFmt4 moves offset to first non-fmt4 byte in x. Returns new offset and EOF flag.

func SkipStringFmt4 added in v1.0.5

func SkipStringFmt4(s string, offset int) (int, bool)

SkipStringFmt4 moves offset to first non-fmt4 byte in string s. Returns new offset and EOF flag.

func ToLower

func ToLower[T byteseq.Byteseq](p T) T

ToLower is an alloc-free replacement of bytes.ToLower() function.

func ToLowerBytes added in v1.0.7

func ToLowerBytes(p []byte) []byte

func ToLowerString added in v1.0.7

func ToLowerString(p string) string

func ToTitle

func ToTitle[T byteseq.Byteseq](p T) T

ToTitle is an alloc-free replacement of bytes.ToTitle() function.

func ToTitleBytes added in v1.0.7

func ToTitleBytes(p []byte) []byte

func ToTitleString added in v1.0.7

func ToTitleString(p string) string

func ToUpper

func ToUpper[T byteseq.Byteseq](p T) T

ToUpper is an alloc-free replacement of bytes.ToUpper() function.

func ToUpperBytes added in v1.0.7

func ToUpperBytes(p []byte) []byte

func ToUpperString added in v1.0.7

func ToUpperString(p string) string

func Trim

func Trim[T byteseq.Q](x, cut T) T

Trim makes fast and alloc-free trim over bytes or string.

func TrimBytes added in v1.0.4

func TrimBytes(p, cut []byte) []byte

TrimBytes makes fast and alloc-free trim over bytes.

func TrimBytesFmt4 added in v1.0.4

func TrimBytesFmt4(p []byte) []byte

TrimBytesFmt4 removes default formatting bytes from both side of p.

func TrimFmt4 added in v1.0.4

func TrimFmt4[T byteseq.Q](x T) T

TrimFmt4 removes default formatting bytes from both side of x.

func TrimLeft

func TrimLeft[T byteseq.Q](p, cut T) T

TrimLeft is a left version of Trim.

func TrimLeftBytes added in v1.0.4

func TrimLeftBytes(p, cut []byte) []byte

TrimLeftBytes is a left version of TrimBytes.

func TrimLeftBytesFmt4 added in v1.0.4

func TrimLeftBytesFmt4(p []byte) []byte

TrimLeftBytesFmt4 removes default formatting bytes from left size of p.

func TrimLeftFmt4 added in v1.0.4

func TrimLeftFmt4[T byteseq.Q](x T) T

TrimLeftFmt4 is a left version of TrimFmt4.

func TrimLeftString added in v1.0.4

func TrimLeftString(p, cut string) string

TrimLeftString is a left version of TrimString.

func TrimLeftStringFmt4 added in v1.0.4

func TrimLeftStringFmt4(p string) string

TrimLeftStringFmt4 removes default formatting bytes from left size of p.

func TrimRight

func TrimRight[T byteseq.Q](p, cut T) T

TrimRight is a right version of Trim.

func TrimRightBytes added in v1.0.4

func TrimRightBytes(p, cut []byte) []byte

TrimRightBytes is a right version of TrimBytes.

func TrimRightBytesFmt4 added in v1.0.4

func TrimRightBytesFmt4(p []byte) []byte

TrimRightBytesFmt4 removes default formatting bytes from right size of p.

func TrimRightFmt4 added in v1.0.4

func TrimRightFmt4[T byteseq.Q](x T) T

TrimRightFmt4 is a right version of TrimFmt4.

func TrimRightString added in v1.0.4

func TrimRightString(p, cut string) string

TrimRightString is a right version of TrimString.

func TrimRightStringFmt4 added in v1.0.4

func TrimRightStringFmt4(p string) string

TrimRightStringFmt4 removes default formatting bytes from right size of p.

func TrimString added in v1.0.4

func TrimString(p, cut string) string

TrimString makes fast and alloc-free trim over string.

func TrimStringFmt4 added in v1.0.4

func TrimStringFmt4(p string) string

TrimStringFmt4 removes default formatting bytes from both side of p.

Types

This section is empty.

Jump to

Keyboard shortcuts

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