at.ac.sbg.cosy.soccerbot.recognition.splitmerge
Class BitSet

java.lang.Object
  extended by at.ac.sbg.cosy.soccerbot.recognition.splitmerge.BitSet

public class BitSet
extends java.lang.Object

Library for storage of sets of single bits

Author:
Peter Wild

Constructor Summary
BitSet()
           
 
Method Summary
static int bitCount(int[] bitSet)
          Returns the total number of bits set to 1 within bitSet
static int calculateSize(int size)
          Calculates the size of a new BitSet as int array which has space for at least size bits and pads the rest (modulo 32)
static void copy(int[] sourceBitSet, int[] targetBitSet)
          Copies source BitSet into target Bitset, requires both BitSets to be initialized and of same length.
static int firstBit(int[] bitSet)
          Returns the index of the first bit set to 1 within bitSet
static int getBit(int[] array, int index)
          Returns a specified bit within a bitset implemented as integer-array
static void releaseBit(int[] array, int index)
          Releases a bit within a bitset implemented as integer-array (sets bit to 0)
static void setBit(int[] array, int index)
          Sets a bit within a bitset implemented as integer-array (sets bit to 1)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitSet

public BitSet()
Method Detail

calculateSize

public static int calculateSize(int size)
Calculates the size of a new BitSet as int array which has space for at least size bits and pads the rest (modulo 32)

Parameters:
size - > 0 number of bits within bitset
Returns:
int array as bit set container

getBit

public static int getBit(int[] array,
                         int index)
Returns a specified bit within a bitset implemented as integer-array

Parameters:
array - initialized bitset
index - >= 0, < array.length * 32 position of bit within bitset
Returns:
0 if bit is not set, 1 if bit is set

setBit

public static void setBit(int[] array,
                          int index)
Sets a bit within a bitset implemented as integer-array (sets bit to 1)

Parameters:
array - initialized bitset
index - >= 0, < array.length * 32 position of bit within bitset

releaseBit

public static void releaseBit(int[] array,
                              int index)
Releases a bit within a bitset implemented as integer-array (sets bit to 0)

Parameters:
array - initialized bitset
index - >= 0, < array.length * 32 position of bit within bitset

bitCount

public static int bitCount(int[] bitSet)
Returns the total number of bits set to 1 within bitSet

Parameters:
bitSet - int array used as a set of bits that can be accessed directly
Returns:
how many bits are set to 1

firstBit

public static int firstBit(int[] bitSet)
Returns the index of the first bit set to 1 within bitSet

Parameters:
bitSet - int array used as a set of bits that can be accessed directly
Returns:
first bit, that is 1

copy

public static void copy(int[] sourceBitSet,
                        int[] targetBitSet)
Copies source BitSet into target Bitset, requires both BitSets to be initialized and of same length.

Parameters:
sourceBitSet - source of deep copy operation
targetBitSet - target of deep copy operation