Top Description Fields Constructors Methods
org.hsqldb.map

public Class BitMap

extends Object
Class Inheritance
Imports
java.util.Arrays

Implementation of a bit map of any size. The map is initialised with the given size with no bits set. The map is fixed length depending on the constructor argument. Static methods to manipulate int, byte and byte[] values as bit maps.
Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.8.0
Version
2.6.1

Field Summary

Modifier and TypeField and Description
private boolean
private int
private int
private int[]

Constructor Summary

AccessConstructor and Description
public
BitMap(int size, boolean extend)

public
BitMap(int[] map)

Method Summary

Modifier and TypeMethod and Description
public static void
and(byte[] map, int pos, byte source, int count)

AND count bits from source with map contents starting at pos

public static byte[]
and(byte[] a, byte[] b)

public int
countSetBits(int from, int limit)

public int
public int
countSetBitsEnd()

Only for word boundary map size

public static int
countSetBitsEnd(int map)

count the run of set bits at the low end

public int
countSetMatches(BitMap other)

Counts the bit positions that are set both in this and the other map.

public static int
countUnsetBitsStart(int map)

count the run of unset bits at the high end

public BitMap
private void
ensureCapacity(int newSize)

Ensures capacity by enlarging the array if necessary.

public int
get(int pos)

public byte[]
public int[]
public static boolean
hasAnyBitSet(byte[] map)

public boolean
isSet(int pos)

public static boolean
isSet(int map, int pos)

public static boolean
isSet(byte map, int pos)

public static boolean
isSet(byte[] map, int pos)

public static byte[]
leftShift(byte[] map, int shiftBits)

public static byte[]
not(byte[] a)

public static void
or(byte[] map, int pos, byte source, int count)

OR count bits from source with map contents starting at pos

public static byte[]
or(byte[] a, byte[] b)

public static void
overlay(byte[] map, int pos, byte source, int count)

overlay count bits from source on map contents starting at pos

public void
reset()

Resets to bits not set with original size

public int
set(int pos)

Sets pos and returns old value

public void
set(BitMap other)

Sets all bits that are set in the other map.

public static int
set(int map, int pos)

public static byte
set(byte map, int pos)

public static void
set(byte[] map, int pos)

public static int
setByte(int map, byte value, int pos)

copy the byte value into the map at given position (0, 24)

private int
setOrUnsetRange(int pos, int count, boolean set)

returns count of bits that change

public int
setRange(int pos, int count)

public void
setSize(int newSize)

public int
setValue(int pos, boolean set)

public int
size()

public int
unset(int pos)

Unsets pos and returns old value

public static int
unset(int map, int pos)

public static void
unset(byte[] map, int pos)

public int
unsetRange(int pos, int count)

public static byte[]
xor(byte[] a, byte[] b)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canChangeSizeback to summary
private boolean canChangeSize
initialSizeback to summary
private int initialSize
limitPosback to summary
private int limitPos
mapback to summary
private int[] map

Constructor Detail

BitMapback to summary
public BitMap(int size, boolean extend)
BitMapback to summary
public BitMap(int[] map)

Method Detail

andback to summary
public static void and(byte[] map, int pos, byte source, int count)

AND count bits from source with map contents starting at pos

andback to summary
public static byte[] and(byte[] a, byte[] b)
countSetBitsback to summary
public int countSetBits(int from, int limit)
countSetBitsback to summary
public int countSetBits()
countSetBitsEndback to summary
public int countSetBitsEnd()

Only for word boundary map size

countSetBitsEndback to summary
public static int countSetBitsEnd(int map)

count the run of set bits at the low end

countSetMatchesback to summary
public int countSetMatches(BitMap other)

Counts the bit positions that are set both in this and the other map.

countUnsetBitsStartback to summary
public static int countUnsetBitsStart(int map)

count the run of unset bits at the high end

duplicateback to summary
public BitMap duplicate()
ensureCapacityback to summary
private void ensureCapacity(int newSize)

Ensures capacity by enlarging the array if necessary. Sets limitPos if capacity is increased.

getback to summary
public int get(int pos)
getBytesback to summary
public byte[] getBytes()
getIntArrayback to summary
public int[] getIntArray()
hasAnyBitSetback to summary
public static boolean hasAnyBitSet(byte[] map)
isSetback to summary
public boolean isSet(int pos)
isSetback to summary
public static boolean isSet(int map, int pos)
isSetback to summary
public static boolean isSet(byte map, int pos)
isSetback to summary
public static boolean isSet(byte[] map, int pos)
leftShiftback to summary
public static byte[] leftShift(byte[] map, int shiftBits)
notback to summary
public static byte[] not(byte[] a)
orback to summary
public static void or(byte[] map, int pos, byte source, int count)

OR count bits from source with map contents starting at pos

orback to summary
public static byte[] or(byte[] a, byte[] b)
overlayback to summary
public static void overlay(byte[] map, int pos, byte source, int count)

overlay count bits from source on map contents starting at pos

resetback to summary
public void reset()

Resets to bits not set with original size

setback to summary
public int set(int pos)

Sets pos and returns old value

setback to summary
public void set(BitMap other)

Sets all bits that are set in the other map.

setback to summary
public static int set(int map, int pos)
setback to summary
public static byte set(byte map, int pos)
setback to summary
public static void set(byte[] map, int pos)
setByteback to summary
public static int setByte(int map, byte value, int pos)

copy the byte value into the map at given position (0, 24)

setOrUnsetRangeback to summary
private int setOrUnsetRange(int pos, int count, boolean set)

returns count of bits that change

setRangeback to summary
public int setRange(int pos, int count)
setSizeback to summary
public void setSize(int newSize)
setValueback to summary
public int setValue(int pos, boolean set)
sizeback to summary
public int size()
unsetback to summary
public int unset(int pos)

Unsets pos and returns old value

unsetback to summary
public static int unset(int map, int pos)
unsetback to summary
public static void unset(byte[] map, int pos)
unsetRangeback to summary
public int unsetRange(int pos, int count)
xorback to summary
public static byte[] xor(byte[] a, byte[] b)