jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Classes | Public Member Functions | List of all members
org.jau.util.Bitfield Interface Reference

Simple bitfield interface for efficient bit storage access in O(1). More...

Inheritance diagram for org.jau.util.Bitfield:
Collaboration diagram for org.jau.util.Bitfield:

Classes

class  Factory
 Simple Bitfield factory for returning the efficient implementation. More...
 

Public Member Functions

int size ()
 Returns the storage size in bit units, e.g. More...
 
void clearField (final boolean bit)
 Set all bits of this bitfield to the given value bit. More...
 
int get32 (final int lowBitnum, final int length) throws IndexOutOfBoundsException
 Returns length bits from this storage, starting with the lowest bit from the storage position lowBitnum. More...
 
void put32 (final int lowBitnum, final int length, final int data) throws IndexOutOfBoundsException
 Puts length bits of given data into this storage, starting w/ the lowest bit to the storage position lowBitnum. More...
 
int copy32 (final int srcLowBitnum, final int dstLowBitnum, final int length) throws IndexOutOfBoundsException
 Copies length bits at position srcLowBitnum to position dstLowBitnum and returning the bits. More...
 
boolean get (final int bitnum) throws IndexOutOfBoundsException
 Return true if the bit at position bitnum is set, otherwise false. More...
 
boolean put (final int bitnum, final boolean bit) throws IndexOutOfBoundsException
 Set or clear the bit at position bitnum according to bit and return the previous value. More...
 
void set (final int bitnum) throws IndexOutOfBoundsException
 Set the bit at position bitnum according to bit. More...
 
void clear (final int bitnum) throws IndexOutOfBoundsException
 Clear the bit at position bitnum according to bit. More...
 
boolean copy (final int srcBitnum, final int dstBitnum) throws IndexOutOfBoundsException
 Copies the bit at position srcBitnum to position dstBitnum and returning true if the bit is set, otherwise false. More...
 
int bitCount ()
 Returns the number of one bits within this bitfield. More...
 

Detailed Description

Simple bitfield interface for efficient bit storage access in O(1).

Since
0.3.0

Definition at line 34 of file Bitfield.java.

Member Function Documentation

◆ bitCount()

int org.jau.util.Bitfield.bitCount ( )

Returns the number of one bits within this bitfield.

Utilizes {#link Bitfield.Util#bitCount(int)}.

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ clear()

void org.jau.util.Bitfield.clear ( final int  bitnum) throws IndexOutOfBoundsException

Clear the bit at position bitnum according to bit.

Parameters
bitnumbit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ clearField()

void org.jau.util.Bitfield.clearField ( final boolean  bit)

Set all bits of this bitfield to the given value bit.

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ copy()

boolean org.jau.util.Bitfield.copy ( final int  srcBitnum,
final int  dstBitnum 
) throws IndexOutOfBoundsException

Copies the bit at position srcBitnum to position dstBitnum and returning true if the bit is set, otherwise false.

Parameters
srcBitnumsource bit number, restricted to [0..size()-1].
dstBitnumdestination bit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ copy32()

int org.jau.util.Bitfield.copy32 ( final int  srcLowBitnum,
final int  dstLowBitnum,
final int  length 
) throws IndexOutOfBoundsException

Copies length bits at position srcLowBitnum to position dstLowBitnum and returning the bits.

Implementation shall operate as if invoking get32(int, int) and then put32(int, int, int) sequentially.

Parameters
srcLowBitnumsource bit number, restricted to [0..size()-1].
dstLowBitnumdestination bit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds
See also
get32(int, int)
put32(int, int, int)

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ get()

boolean org.jau.util.Bitfield.get ( final int  bitnum) throws IndexOutOfBoundsException

Return true if the bit at position bitnum is set, otherwise false.

Parameters
bitnumbit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ get32()

int org.jau.util.Bitfield.get32 ( final int  lowBitnum,
final int  length 
) throws IndexOutOfBoundsException

Returns length bits from this storage, starting with the lowest bit from the storage position lowBitnum.

Parameters
lowBitnumstorage bit position of the lowest bit, restricted to [0..size()-length].
lengthnumber of bits to read, constrained to [0..32].
Exceptions
IndexOutOfBoundsExceptionif rightBitnum is out of bounds
See also
put32(int, int, int)

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ put()

boolean org.jau.util.Bitfield.put ( final int  bitnum,
final boolean  bit 
) throws IndexOutOfBoundsException

Set or clear the bit at position bitnum according to bit and return the previous value.

Parameters
bitnumbit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ put32()

void org.jau.util.Bitfield.put32 ( final int  lowBitnum,
final int  length,
final int  data 
) throws IndexOutOfBoundsException

Puts length bits of given data into this storage, starting w/ the lowest bit to the storage position lowBitnum.

Parameters
lowBitnumstorage bit position of the lowest bit, restricted to [0..size()-length].
lengthnumber of bits to write, constrained to [0..32].
datathe actual bits to be put into this storage
Exceptions
IndexOutOfBoundsExceptionif rightBitnum is out of bounds
See also
get32(int, int)

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ set()

void org.jau.util.Bitfield.set ( final int  bitnum) throws IndexOutOfBoundsException

Set the bit at position bitnum according to bit.

Parameters
bitnumbit number, restricted to [0..size()-1].
Exceptions
IndexOutOfBoundsExceptionif bitnum is out of bounds

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

◆ size()

int org.jau.util.Bitfield.size ( )

Returns the storage size in bit units, e.g.

32 bit for implementations using one int field.

Implemented in jau.util.Int32ArrayBitfield, jau.util.Int32Bitfield, and jau.util.SyncedBitfield.

Here is the caller graph for this function:

The documentation for this interface was generated from the following file: