Expand description
A module for implementing some helpful functions for monotree
.
Functions
- Get
i
-th bit from bytes slice. Indexi
starts from 0. - Convert bits, Vec slice of
bool
into bytes,Vec<u8>
. - Convert a Vec slice of bit or
bool
into a number asusize
. - Convert a bytes slice into a Vec of bit.
- Convert big-endian bytes into base10 or decimal number.
- Convert (bytes slice + Range) representation into bits in forms of
Vec<bool>
. - Cast from a typed scalar to another based on
num_traits
- Get sorted indices from unsorted slice.
- Get a compressed bytes (leading-zero-truncated big-endian bytes) from a
u64
. - Get length of the longest common prefix bits for the given two slices.
- Get the required length of bytes from a
Range
, bits indices across the bytes. - Adjust the bytes representation for
Bits
when shifted. Returns a bytes shift,n
and thereby resulting shifted range,R
. - Generate a random byte based on
rand::random
. - Generate random bytes of the given length.
- Generate a random
Hash
, byte-array ofHASH_LEN
length. - Generate a vector of random
Hash
with the given length. - Shuffle a slice using Fisher-Yates algorithm.
- Get a fixed lenght byte-array or
Hash
from slice.