Table of Contents

Class BitArray

Namespace
ZXing.Common
Assembly
zxing.dll

A simple, fast array of bits, represented compactly by an array of ints internally.

public sealed class BitArray
Inheritance
BitArray
Inherited Members

Constructors

BitArray()

default constructor

public BitArray()

BitArray(int)

initializing constructor

public BitArray(int size)

Parameters

size int

desired size of the array

Properties

Array

public int[] Array { get; }

Property Value

int[]

underlying array of ints. The first element holds the first 32 bits, and the least significant bit is bit 0.

this[int]

index accessor

public bool this[int i] { get; set; }

Parameters

i int

Property Value

bool

Size

size of the array, number of elements

public int Size { get; }

Property Value

int

SizeInBytes

size of the array in bytes

public int SizeInBytes { get; }

Property Value

int

Methods

Clone()

Erstellt ein neues Objekt, das eine Kopie der aktuellen Instanz darstellt.

public object Clone()

Returns

object

Ein neues Objekt, das eine Kopie dieser Instanz darstellt.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object o)

Parameters

o object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

appendBit(bool)

Appends the bit.

public void appendBit(bool bit)

Parameters

bit bool

The bit.

appendBitArray(BitArray)

adds the array to the end

public void appendBitArray(BitArray other)

Parameters

other BitArray

appendBits(int, int)

Appends the least-significant bits, from value, in order from most-significant to least-significant. For example, appending 6 bits from 0x000001E will append the bits 0, 1, 1, 1, 1, 0 in that order.

public void appendBits(int value, int numBits)

Parameters

value int

int containing bits to append

numBits int

bits from value to append

clear()

Clears all bits (sets to false).

public void clear()

flip(int)

Flips bit i.

public void flip(int i)

Parameters

i int

bit to set

getNextSet(int)

Gets the next set.

public int getNextSet(int from)

Parameters

from int

first bit to check

Returns

int

index of first bit that is set, starting from the given index, or size if none are set at or beyond this given index

getNextUnset(int)

see getNextSet(int)

public int getNextUnset(int from)

Parameters

from int

index to start looking for unset bit

Returns

int

index of next unset bit, or Size if none are unset until the end

isRange(int, int, bool)

Efficient method to check if a range of bits is set, or not set.

public bool isRange(int start, int end, bool value)

Parameters

start int

start of range, inclusive.

end int

end of range, exclusive

value bool

if true, checks that bits in range are set, otherwise checks that they are not set

Returns

bool

true iff all bits are set or not set in range, according to value argument

reverse()

Reverses all bits in the array.

public void reverse()

setBulk(int, int)

Sets a block of 32 bits, starting at bit i.

public void setBulk(int i, int newBits)

Parameters

i int

first bit to set

newBits int

the new value of the next 32 bits. Note again that the least-significant bit corresponds to bit i, the next-least-significant to i+1, and so on.

setRange(int, int)

Sets a range of bits.

public void setRange(int start, int end)

Parameters

start int

start of range, inclusive.

end int

end of range, exclusive

toBytes(int, byte[], int, int)

converts to bytes.

public void toBytes(int bitOffset, byte[] array, int offset, int numBytes)

Parameters

bitOffset int

first bit to start writing

array byte[]

array to write into. Bytes are written most-significant byte first. This is the opposite of the internal representation, which is exposed by BitArray

offset int

position in array to start writing

numBytes int

how many bytes to write

xor(BitArray)

XOR operation

public void xor(BitArray other)

Parameters

other BitArray