hamming

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2015 License: MIT, MIT Imports: 0 Imported by: 0

README

hamming distance calculations in Go

Copyright © 2014, 2015 Barry Allard

MIT license

Usage

import 'github.com/steakknife/hamming'

// ...

// hamming distance between values
hamming.Byte(0xFF, 0x00) // 8
hamming.Byte(0x00, 0x00) // 0

// just count bits in a byte
hamming.CountBitsByte(0xA5), // 4

See help in the docs

Get

go get -u github.com/steakknife/hamming  # master is always stable

Source

Contact

License

MIT license

Copyright © 2014, 2015 Barry Allard

Documentation

Overview

hamming distance calculations in Go

https://github.com/steakknife/hamming

MIT license

Usage

The functions are named (CountBits)?(Byte|Uint64)s?. The plural forms are for slices. The CountBits.+ forms are Population Count only, where the bare-type forms are Hamming distance.

import 'github.com/steakknife/hamming'

// ...

// hamming distance between values
hamming.Byte(0xFF, 0x00) // 8
hamming.Byte(0x00, 0x00) // 0

// just count bits in a byte
hamming.CountBitsByte(0xA5), // 4

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Byte

func Byte(x, y byte) int

hamming distance of two bytes

func Bytes

func Bytes(b0, b1 []byte) int

hamming distance of two byte buffers, of which the size of the first argument is used for both (panics if b1 is smaller than b0, does not compare b1 beyond length of b0)

func CountBitsByte

func CountBitsByte(x byte) int

func CountBitsBytes

func CountBitsBytes(b []byte) int

func CountBitsUint64

func CountBitsUint64(x uint64) int

func CountBitsUint64s

func CountBitsUint64s(b []uint64) int

func Uint64

func Uint64(x, y uint64) int

hamming distance of two uint64's

func Uint64s

func Uint64s(b0, b1 []uint64) int

hamming distance of two uint64 buffers, of which the size of the first argument is used for both (panics if b1 is smaller than b0, does not compare b1 beyond length of b0)

Types

This section is empty.

Jump to

Keyboard shortcuts

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