# Functions
Accumulate8 returns the sum of the (unsigned) bytes in src[].
Accumulate8Greater returns the sum of all bytes in src[] greater than the given value.
AddConst8 sets dst[pos] := src[pos] + val for every byte in src (with the usual unsigned overflow).
AddConst8Inplace adds the given constant to every byte of main[], with unsigned overflow.
AddConst8Unsafe sets dst[pos] := src[pos] + val for every byte in src (with the usual unsigned overflow).
AddConst8UnsafeInplace adds the given constant to every byte of main[], with unsigned overflow.
And sets dst[pos] := src1[pos] & src2[pos] for every position in dst.
AndConst8 sets dst[pos] := src[pos] & val for every position in dst.
AndConst8Inplace sets main[pos] := main[pos] & val for every position in main[].
AndConst8Unsafe sets dst[pos] := src[pos] & val for every position in dst.
AndConst8UnsafeInplace sets main[pos] := main[pos] & val for every position in main[].
AndInplace sets main[pos] := arg[pos] & main[pos] for every position in main[].
AndUnsafe sets dst[pos] := src1[pos] & src2[pos] for every position in dst.
AndUnsafeInplace sets main[pos] := main[pos] & arg[pos] for every position in main[].
BitFromEveryByte fills dst[] with a bitarray containing every 8th bit from src[], starting with bitIdx, where bitIdx is in [0,7].
BytesPerVec is an accessor for the bytesPerVec package variable.
Count2Bytes counts the number of bytes in src[] which are equal to either val1 or val2.
Count3Bytes counts the number of bytes in src[] which are equal to val1, val2, or val3.
CountNibblesInSet counts the number of nibbles in src[] which are in the given set.
CountNibblesInTwoSets counts the number of bytes in src[] which are in the given two sets, assuming all bytes are <16.
CountUnpackedNibblesInSet counts the number of bytes in src[] which are in the given set, assuming all bytes are <16.
CountUnpackedNibblesInTwoSets counts the number of bytes in src[] which are in the given two sets, assuming all bytes are <16.
DivUpPow2 efficiently divides a number by a power-of-2 divisor.
FindNaNOrInf64 returns the position of the first NaN/inf value if one is present, and -1 otherwise.
FirstGreater8 scans arg[startPos:] for the first value larger than the given constant, returning its position if one is found, or len(arg) if all bytes are <= (or startPos >= len).
FirstGreater8Unsafe scans arg[startPos:] for the first value larger than the given constant, returning its position if one is found, or len(arg) if all bytes are <= (or startPos >= len).
FirstLeq8 scans arg[startPos:] for the first value <= the given constant, returning its position if one is found, or len(arg) if all bytes are greater (or startPos >= len).
FirstLeq8Unsafe scans arg[startPos:] for the first value <= the given constant, returning its position if one is found, or len(arg) if all bytes are greater (or startPos >= len).
FirstUnequal8 scans arg1[startPos:] and arg2[startPos:] for the first mismatching byte, returning its position if one is found, or the common length if all bytes match (or startPos >= len).
FirstUnequal8Unsafe scans arg1[startPos:] and arg2[startPos:] for the first mismatching byte, returning its position if one is found, or the common length if all bytes match (or startPos >= len).
IndexU16 returns the index of the first instance of val in main, or -1 if val is not present in main.
Interleave8 sets the bytes in dst[] as follows: if pos is even, dst[pos] := even[pos/2] if pos is odd, dst[pos] := odd[pos/2] It panics if ((len(dst) + 1) / 2) != len(even), or (len(dst) / 2) != len(odd).
Interleave8Unsafe sets the bytes in dst[] as follows: if pos is even, dst[pos] := even[pos/2] if pos is odd, dst[pos] := odd[pos/2]
WARNING: This is a function designed to be used in inner loops, which makes assumptions about length and capacity which aren't checked at runtime.
Invmask sets dst[pos] := src1[pos] &^ src2[pos] for every position in dst.
InvmaskConst8 sets dst[pos] := src[pos] &^ val for every position in dst.
InvmaskConst8Inplace sets main[pos] := main[pos] &^ val for every position in main[].
InvmaskConst8Unsafe sets dst[pos] := src[pos] &^ val for every position in dst.
InvmaskConst8UnsafeInplace sets main[pos] := main[pos] &^ val for every position in main[].
InvmaskInplace sets main[pos] := arg[pos] &^ main[pos] for every position in main[].
InvmaskUnsafe sets dst[pos] := src1[pos] &^ src2[pos] for every position in dst.
InvmaskUnsafeInplace sets main[pos] := main[pos] &^ arg[pos] for every position in main[].
MakeNibbleLookupTable generates a NibbleLookupTable from a [16]byte.
MakeUnsafe returns a byte slice of the given length which is guaranteed to have enough capacity for all Unsafe functions in this package to work.
MaskThenCountByte counts the number of bytes in src[] satisfying src[pos] & mask == val.
Memset16Raw assumes dst points to an array of nElem 2-byte elements, and valPtr points to a single 2-byte element.
Memset32Raw assumes dst points to an array of nElem 4-byte elements, and valPtr points to a single 4-byte element.
Memset8 sets all values of dst[] to the given byte.
Memset8Unsafe sets all values of dst[] to the given byte.
Or sets dst[pos] := src1[pos] | src2[pos] for every position in dst.
OrConst8 sets dst[pos] := src[pos] | val for every position in dst.
OrConst8Inplace sets main[pos] := main[pos] | val for every position in main[].
OrConst8Unsafe sets dst[pos] := src[pos] | val for every position in dst.
OrConst8UnsafeInplace sets main[pos] := main[pos] | val for every position in main[].
OrInplace sets main[pos] := arg[pos] | main[pos] for every position in main[].
OrUnsafe sets dst[pos] := src1[pos] | src2[pos] for every position in dst.
OrUnsafeInplace sets main[pos] := main[pos] | arg[pos] for every position in main[].
PackedNibbleLookup sets the bytes in dst[] as follows: if pos is even, dst[pos] := table[src[pos / 2] & 15] if pos is odd, dst[pos] := table[src[pos / 2] >> 4] It panics if len(src) != (len(dst) + 1) / 2.
PackedNibbleLookupUnsafe sets the bytes in dst[] as follows: if pos is even, dst[pos] := table[src[pos / 2] & 15] if pos is odd, dst[pos] := table[src[pos / 2] >> 4]
WARNING: This is a function designed to be used in inner loops, which makes assumptions about length and capacity which aren't checked at runtime.
Popcnt returns the number of set bits in the given []byte.
PopcntUnsafe returns the number of set bits in the given []byte, assuming that any trailing bytes up to the next multiple of BytesPerWord are zeroed out.
RemakeUnsafe reuses the given buffer if it has sufficient capacity; otherwise it does the same thing as MakeUnsafe.
RepeatI16 fills dst[] with the given int16.
RepeatU16 fills dst[] with the given uint16.
ResizeUnsafe changes the length of buf and ensures it has enough extra capacity to be passed to this package's Unsafe functions.
Reverse16InplaceRaw assumes main points to an array of ct 2-byte elements, and reverses it in-place.
Reverse16Raw assumes dst and src both point to arrays of ct 2-byte elements, and sets dst[pos] := src[ct - 1 - pos] for each position.
Reverse8 sets dst[pos] := src[len(src) - 1 - pos] for every position in src.
Reverse8Inplace reverses the bytes in main[].
Reverse8Unsafe sets dst[pos] := src[len(src) - 1 - pos] for every position in src.
ReverseI16 sets dst[len(src) - 1 - pos] := src[pos] for each position in src.
ReverseI16Inplace reverses a []int16 in-place.
ReverseU16 sets dst[len(src) - 1 - pos] := src[pos] for each position in src.
ReverseU16Inplace reverses a []uint16 in-place.
RoundUpPow2 returns val rounded up to a multiple of alignment, assuming alignment is a power of 2.
SubtractFromConst8 sets dst[pos] := val - src[pos] for every byte in src (with the usual unsigned overflow).
SubtractFromConst8Inplace subtracts every byte of main[] from the given constant, with unsigned underflow.
SubtractFromConst8Unsafe sets dst[pos] := val - src[pos] for every byte in src (with the usual unsigned overflow).
SubtractFromConst8UnsafeInplace subtracts every byte of main[] from the given constant, with unsigned underflow.
UnpackedNibbleLookup sets the bytes in dst[] as follows: if src[pos] < 128, set dst[pos] := table[src[pos] & 15] otherwise, set dst[pos] := 0 It panics if len(src) != len(dst).
UnpackedNibbleLookupInplace replaces the bytes in main[] as follows: if value < 128, set to table[value & 15] otherwise, set to 0.
UnpackedNibbleLookupS is a variant of UnpackedNibbleLookup() that takes string src.
UnpackedNibbleLookupUnsafe sets the bytes in dst[] as follows: if src[pos] < 128, set dst[pos] := table[src[pos] & 15] otherwise, set dst[pos] := 0
WARNING: This is a function designed to be used in inner loops, which makes assumptions about length and capacity which aren't checked at runtime.
UnpackedNibbleLookupUnsafeInplace replaces the bytes in main[] as follows: if value < 128, set to table[value & 15] otherwise, set to 0
WARNING: This is a function designed to be used in inner loops, which makes assumptions about capacity which aren't checked at runtime.
XcapUnsafe is shorthand for ResizeUnsafe's most common use case (no length change, just want to ensure sufficient capacity).
Xor sets dst[pos] := src1[pos] ^ src2[pos] for every position in dst.
XorConst8 sets dst[pos] := src[pos] ^ val for every position in dst.
XorConst8Inplace sets main[pos] := main[pos] ^ val for every position in main[].
XorConst8Unsafe sets dst[pos] := src[pos] ^ val for every position in dst.
XorConst8UnsafeInplace sets main[pos] := main[pos] ^ val for every position in main[].
XorInplace sets main[pos] := arg[pos] ^ main[pos] for every position in main[].
XorUnsafe sets dst[pos] := src1[pos] ^ src2[pos] for every position in dst.
XorUnsafeInplace sets main[pos] := main[pos] ^ arg[pos] for every position in main[].
# Constants
BitsPerWord is the number of bits in a machine word.
BytesPerWord is the number of bytes in a machine word.
Log2BytesPerWord is log2(BytesPerWord).
# Structs
NibbleLookupTable represents a parallel-byte-substitution operation f, where every byte b in a byte-slice is replaced with f(b) := shuffle[0][b & 15] for b <= 127, and f(b) := 0 for b > 127.