bitutil

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: CC0-1.0 Imports: 4 Imported by: 4

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSizeString

func ByteSizeString(size int64, useISU bool) string

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

func CompareByteArray(arr1 []byte, arr2 []byte) bool

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

func HexDump(data []byte) string

HexDump produces a more-or-less human readable hex dump from a given byte array slice.

func MurMurHashData

func MurMurHashData(data []byte, offset int, size int, seed int) (uint32, error)

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

func PackList(unpackedlist []uint64, highest uint64) string

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

func PackList16Bit(list []uint16) string

PackList16Bit packs a list of 16 bit numbers.

func PackList2Bit

func PackList2Bit(list []byte) string

PackList2Bit packs a list of bytes into a string using 2 bits for each item. (Items must be between 1 and 3)

func PackList32Bit

func PackList32Bit(list []uint32) string

PackList32Bit packs a list of 32 bit numbers.

func PackList3Bit

func PackList3Bit(list []byte) string

PackList3Bit packs a list of bytes into a string using 3 bits for each item. (Items must be between 1 and 7)

func PackList64Bit

func PackList64Bit(list []uint64) string

PackList64Bit packs a list of 64 bit numbers.

func PackList6Bit

func PackList6Bit(list []byte) string

PackList6Bit packs a list of bytes into a string using 6 bits for each item. (Items must be between 1 and 63)

func PackList8Bit

func PackList8Bit(list []uint8) string

PackList8Bit packs a list of 8 bit numbers.

func UnpackBigList

func UnpackBigList(packedlist string) []uint64

UnpackBigList unpacks a list which has large values.

func UnpackList

func UnpackList(packedlist string) []uint64

UnpackList unpacks a list from a packed string.

func UnpackSmallList

func UnpackSmallList(packedlist string) []byte

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.

Jump to

Keyboard shortcuts

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