utils

package
v0.0.0-...-5a0018c Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2014 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package utils contain some utilities which are needed to create barcodes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntToRune

func IntToRune(i int) rune

IntToRune converts a digit 0 - 9 to the rune '0' - '9'. If the given int is outside of this range 'F' is returned!

func New1DCode

func New1DCode(codeKind, content string, bars *BitList) barcode.Barcode

New1DCode creates a new 1D barcode where the bars are represented by the bits in the bars BitList

func RuneToInt

func RuneToInt(r rune) int

RuneToInt converts a rune between '0' and '9' to an integer between 0 and 9 If the rune is outside of this range -1 is returned.

Types

type BitList

type BitList struct {
	// contains filtered or unexported fields
}

BitList is a list that contains bits

func NewBitList

func NewBitList(capacity int) *BitList

NewBitList returns a new BitList with the given length all bits are initialize with false

func (*BitList) AddBit

func (bl *BitList) AddBit(bits ...bool)

AddBit appends the given bits to the end of the list

func (*BitList) AddBits

func (bl *BitList) AddBits(b int, count byte)

AddBits appends the last (LSB) 'count' bits of 'b' the the end of the list

func (*BitList) AddByte

func (bl *BitList) AddByte(b byte)

AddByte appends all 8 bits of the given byte to the end of the list

func (*BitList) GetBit

func (bl *BitList) GetBit(index int) bool

GetBit returns the bit at the given index

func (*BitList) GetBytes

func (bl *BitList) GetBytes() []byte

GetBytes returns all bits of the BitList as a []byte

func (*BitList) IterateBytes

func (bl *BitList) IterateBytes() <-chan byte

IterateBytes iterates through all bytes contained in the BitList

func (*BitList) Len

func (bl *BitList) Len() int

Len returns the number of contained bits

func (*BitList) SetBit

func (bl *BitList) SetBit(index int, value bool)

SetBit sets the bit at the given index to the given value

type GaloisField

type GaloisField struct {
	ALogTbl []int
	LogTbl  []int
}

GaloisField encapsulates galois field arithmetics

func NewGaloisField

func NewGaloisField(pp int) *GaloisField

NewGaloisField creates a new falois field

func (*GaloisField) AddOrSub

func (gf *GaloisField) AddOrSub(a, b int) int

AddOrSub add or substract two numbers

func (*GaloisField) Divide

func (gf *GaloisField) Divide(a, b int) int

Divide divides two numbers

func (*GaloisField) Multiply

func (gf *GaloisField) Multiply(a, b int) int

Multiply multiplys two numbers

Jump to

Keyboard shortcuts

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