org.egothor.util
Class Bitmap

java.lang.Object
  extended by org.egothor.util.Bitmap

public class Bitmap
extends java.lang.Object

The Bitmap object is an implementation of a bit map. Bitmap can be used for setting bits, getting states of bits. It can also be stored or loaded from a data stream.

This implementation divides the entire bit map into smaller blocks. If the block does not contain any 1-bits (the default, initial state) it is not stored in this object.

Author:
Leo Galambos

Constructor Summary
Bitmap()
          The default constructor for the Bitmap object.
Bitmap(Bitmap master)
          Create a copy of the master.
Bitmap(DataInput is)
          Construct a Bitmap object using the given input stream.
 
Method Summary
 Bitmap and(Bitmap with)
           
 long findNextSet(long from)
          Return the next bit set starting at the bit of index from.
 long findNextUnset(long from)
          Return the next bit unset starting at the bit of index from.
 byte getBit(int num)
          Return the state of the specified bit (the first bit is 0).
 IListReader getIListReader(java.lang.String term)
           
 int getSets()
          Returns the total number of 1-bits in the bit map.
 boolean isDirty()
          Test whether the Bitmap has been modified.
 Bitmap or(Bitmap with)
           
 boolean setBit(int num)
          Set the bit at index num to 1.
 void store(DataOutput os)
          Write this object to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bitmap

public Bitmap(DataInput is)
       throws java.io.IOException
Construct a Bitmap object using the given input stream.

Parameters:
is - the input stream.
Throws:
java.io.IOException - Description of the Exception

Bitmap

public Bitmap()
The default constructor for the Bitmap object.


Bitmap

public Bitmap(Bitmap master)
Create a copy of the master.

Method Detail

setBit

public boolean setBit(int num)
Set the bit at index num to 1.

Parameters:
num - The new bit value

and

public Bitmap and(Bitmap with)

or

public Bitmap or(Bitmap with)

getBit

public byte getBit(int num)
Return the state of the specified bit (the first bit is 0).

Parameters:
num - the bit to check
Returns:
0 if the bit is off (it is set to 0).

isDirty

public boolean isDirty()
Test whether the Bitmap has been modified.

Returns:
true if it has, false otherwise

getSets

public int getSets()
Returns the total number of 1-bits in the bit map.

Returns:
the number of 1-bits

store

public void store(DataOutput os)
           throws java.io.IOException
Write this object to the given output stream.

Parameters:
os - the output stream
Throws:
java.io.IOException - Description of the Exception

getIListReader

public IListReader getIListReader(java.lang.String term)

findNextSet

public long findNextSet(long from)
Return the next bit set starting at the bit of index from. If none bit exists, -1 is returned.


findNextUnset

public long findNextUnset(long from)
Return the next bit unset starting at the bit of index from. If none bit exists, from is returned (as obvious).