bitarray

package module
v0.0.0-...-b3db261 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: MIT Imports: 3 Imported by: 1

README

BitArray

GoDoc

Provides a structure for efficiently representing arrays of k-bit elements.

a := bitarray.New(3, 6) // Makes an array of 3 items of 6 bits each
a.Set(0, 0x2b)
a.Set(1, 0x1c)
a.Set(2, 0x3a)

a.Get(1) // == 0x1c

Documentation

Overview

Package bitarray provides a structure for representing arrays of k-bit elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

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

func New

func New(n int, k uint) Array

Returns a new bit array with n elements of k bits each. k <= 64.

func (*Array) Get

func (a *Array) Get(i int) uint64

Get the item at i as the bottom k bits of the result. Panics if i is out of bounds.

func (*Array) K

func (a *Array) K() uint

Returns the length, in bits, of each element.

func (*Array) Len

func (a *Array) Len() int

Returns the number of elements in the array.

func (*Array) Set

func (a *Array) Set(i int, v uint64)

Sets the item at i to be the bottom k bits of v. Panics if v is more than k bits, or if i is out of bounds.

Jump to

Keyboard shortcuts

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