com.aelitis.azureus.core.peermanager.piecepicker.util
Class BitFlags

java.lang.Object
  extended by com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags
All Implemented Interfaces:
Cloneable

public class BitFlags
extends Object
implements Cloneable

Author:
MjrTom A fairly light-weight, versatile boolean array of bit flags with administrative fields and methods Originaly designed as a boolean array to correspond to the pieces in a torrent, for example to show which pieces are; downloading, high priority, rarest, available, or whatever. This class is subject to experimentation, although the important uses of the class must NOT be broken.

Field Summary
 int end
          Index of last set bit
 boolean[] flags
          The array of bit flags
 int nbSet
          how many bits are set
 int start
          Index of first set bit
 
Constructor Summary
BitFlags(BitFlags other)
          clone constructor
BitFlags(boolean[] _flags)
           
BitFlags(int count)
           
 
Method Summary
 BitFlags and(BitFlags other)
          Experimental.
 void clear()
           
 Object clone()
           
 boolean equals(Object o)
           
 int hashCode()
           
 void set(int i)
          for setting a flag that is not known to be the first or last, or not
 void setAll()
           
 void setEnd(int i)
          this is for setting a flag that is already known to be the last true flag
 void setOnly(int i)
          clears the array then sets the given flag
 void setStart(int i)
          for setting a flag that is already known to be the first true flag
 int size()
          You can read flags.length instead (but please don't modify it)
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

public int start
Index of first set bit


end

public int end
Index of last set bit


nbSet

public int nbSet
how many bits are set


flags

public final boolean[] flags
The array of bit flags

Constructor Detail

BitFlags

public BitFlags(int count)

BitFlags

public BitFlags(boolean[] _flags)

BitFlags

public BitFlags(BitFlags other)
clone constructor

Method Detail

clone

public Object clone()
Overrides:
clone in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

size

public int size()
You can read flags.length instead (but please don't modify it)

Returns:
the number of elements in this array

clear

public void clear()

setStart

public void setStart(int i)
for setting a flag that is already known to be the first true flag


set

public void set(int i)
for setting a flag that is not known to be the first or last, or not


setEnd

public void setEnd(int i)
this is for setting a flag that is already known to be the last true flag


setOnly

public void setOnly(int i)
clears the array then sets the given flag


setAll

public void setAll()

and

public BitFlags and(BitFlags other)
Experimental. Returns a new BitFlags with flags set as the logical AND of both BitFlags. The length of both must be the same.

Parameters:
other - BitFlags to be ANDed with this BitFlags. Must not be null.
Returns:
new BitFlags representing the logical AND of the two