Documentation ¶
Overview ¶
Package bitutil contains common function for bit-level operations.
Pack and Unpack functions are used to pack and unpack a list of non-zero numbers very efficiently.
Index ¶
- func ByteSizeString(size int64, useISU bool) string
- func CompareByteArray(arr1 []byte, arr2 []byte) bool
- func HexDump(data []byte) string
- func MurMurHashData(data []byte, offset int, size int, seed int) (uint32, error)
- func PackList(unpackedlist []uint64, highest uint64) string
- func PackList16Bit(list []uint16) string
- func PackList2Bit(list []byte) string
- func PackList32Bit(list []uint32) string
- func PackList3Bit(list []byte) string
- func PackList64Bit(list []uint64) string
- func PackList6Bit(list []byte) string
- func PackList8Bit(list []uint8) string
- func UnpackBigList(packedlist string) []uint64
- func UnpackList(packedlist string) []uint64
- func UnpackSmallList(packedlist string) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSizeString ¶
ByteSizeString takes a numeric byte size and returns it in human readable form. The useISU parameter determines which units to use. False uses the more common binary form. The units kibibyte, mebibyte, etc were established by the International Electrotechnical Commission (IEC) in 1998.
useISU = True -> Decimal (as formally defined in the International System of Units) Bytes / Metric 1000^1 kB kilobyte 1000^2 MB megabyte 1000^3 GB gigabyte 1000^4 TB terabyte 1000^5 PB petabyte 1000^6 EB exabyte
useISU = False -> Binary (as defined by the International Electrotechnical Commission) Bytes / Metric 1024^1 KiB kibibyte 1024^2 MiB mebibyte 1024^3 GiB gibibyte 1024^4 TiB tebibyte 1024^5 PiB pebibyte 1024^6 EiB exbibyte
func CompareByteArray ¶
CompareByteArray compares the contents of two byte array slices. Returns true if both slices are equivalent in terms of size and content. The capacity may be different.
func HexDump ¶
HexDump produces a more-or-less human readable hex dump from a given byte array slice.
func MurMurHashData ¶
MurMurHashData hashes a given array of bytes. This is an implementation of Austin Appleby's MurmurHash3 (32bit) function.
Reference implementation: http://code.google.com/p/smhasher/wiki/MurmurHash3
func PackList ¶
PackList packs a given list to a string. Depending on the given highest number the list is packed in the most efficient way.
func PackList16Bit ¶
PackList16Bit packs a list of 16 bit numbers.
func PackList2Bit ¶
PackList2Bit packs a list of bytes into a string using 2 bits for each item. (Items must be between 1 and 3)
func PackList32Bit ¶
PackList32Bit packs a list of 32 bit numbers.
func PackList3Bit ¶
PackList3Bit packs a list of bytes into a string using 3 bits for each item. (Items must be between 1 and 7)
func PackList64Bit ¶
PackList64Bit packs a list of 64 bit numbers.
func PackList6Bit ¶
PackList6Bit packs a list of bytes into a string using 6 bits for each item. (Items must be between 1 and 63)
func PackList8Bit ¶
PackList8Bit packs a list of 8 bit numbers.
func UnpackBigList ¶
UnpackBigList unpacks a list which has large values.
func UnpackList ¶
UnpackList unpacks a list from a packed string.
func UnpackSmallList ¶
UnpackSmallList unpacks a string into a list of bytes. Returns the list of bytes or a list of a single 0x00 byte if the numbers in the list are too big.
Types ¶
This section is empty.