mesquite.lib
Class Bits

java.lang.Object
  extended by mesquite.lib.Bits
All Implemented Interfaces:
Listable

public class Bits
extends java.lang.Object
implements Listable

Bits - an object to contain and manage a field of booleans. This was invented before the Java Bitfield was discovered. Perhaps not needed.


Constructor Summary
Bits(int numBits)
           
 
Method Summary
static boolean[] addParts(boolean[] d, int starting, int num)
          Inserts num (cleared) bits just after bit "starting"
 void addParts(int starting, int num)
          Inserts num (cleared) bits just after bit "starting"
static boolean[][] addRows(boolean[][] d, int starting, int num)
           
 boolean anyBitsOn()
           
 void clearAllBits()
           
 void clearBit(int whichBit)
           
 Bits cloneBits()
           
 void copyBits(Bits b)
           
static boolean[] deleteParts(boolean[] values, int starting, int num)
           
 void deleteParts(int starting, int num)
          Removes num bits starting with and incuding bit "starting"
static boolean[][] deleteRows(boolean[][] d, int starting, int num)
           
 boolean equals(Bits other)
           
 int firstBitOn()
           
 java.lang.String getListOfBitsOn(int offset)
          returns a string listing the bits on.
 java.lang.String getName()
           
 NameReference getNameReference()
           
 int getNumInts()
           
 int getSize()
           
 boolean isBitOn(int whichBit)
           
static boolean isBitOn(int[] bits, int whichBit)
           
static void moveColumns(boolean[][] d, int starting, int num, int justAfter)
           
 void moveParts(int starting, int num, int justAfter)
           
static void moveRows(boolean[][] d, int starting, int num, int justAfter)
           
 int nextBit(int startBit, boolean on)
          returns the next bit, starting a startBit, that has the same value as "on"
 int numBitsOn()
           
 int numBitsOnPlural()
           
 boolean oneBitOn(MesquiteInteger single)
          Returns true iff exactly one bit is on.
 void resetSize(int newNumBits)
           
static boolean[] reverseBooleanArray(boolean[] d)
          Reverses the elements of a boolean array
 void setAllBits()
           
 void setBit(int whichBit)
           
 void setBit(int[] a, int whichBit)
           
 void setBit(int whichBit, boolean on)
           
 void setNameReference(NameReference nr)
           
static void swapColumns(boolean[][] d, int first, int second)
           
 void swapParts(int first, int second)
           
 void swapValues(int i, int j)
           
 java.lang.String toString()
           
static java.lang.String toString(boolean[] bits)
           
static java.lang.String toString(byte s)
          converts passed int to string, as its bits representation.
static java.lang.String toString(int s)
          converts passed int to string, as its bits representation.
static java.lang.String toString(int[] bits)
           
static java.lang.String toString(long s)
          converts passed long to string, as its bits representation.
static java.lang.String toString(short s)
          converts passed int to string, as its bits representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bits

public Bits(int numBits)
Method Detail

getSize

public int getSize()

getNumInts

public int getNumInts()

cloneBits

public Bits cloneBits()

copyBits

public void copyBits(Bits b)

setNameReference

public void setNameReference(NameReference nr)

getNameReference

public NameReference getNameReference()

getName

public java.lang.String getName()
Specified by:
getName in interface Listable

resetSize

public void resetSize(int newNumBits)

addParts

public void addParts(int starting,
                     int num)
Inserts num (cleared) bits just after bit "starting"


deleteParts

public void deleteParts(int starting,
                        int num)
Removes num bits starting with and incuding bit "starting"


swapParts

public void swapParts(int first,
                      int second)

moveParts

public void moveParts(int starting,
                      int num,
                      int justAfter)

numBitsOn

public int numBitsOn()

numBitsOnPlural

public int numBitsOnPlural()

clearAllBits

public void clearAllBits()

setAllBits

public void setAllBits()

clearBit

public void clearBit(int whichBit)

setBit

public void setBit(int[] a,
                   int whichBit)

setBit

public void setBit(int whichBit)

setBit

public void setBit(int whichBit,
                   boolean on)

swapValues

public void swapValues(int i,
                       int j)

equals

public boolean equals(Bits other)

isBitOn

public boolean isBitOn(int whichBit)

isBitOn

public static boolean isBitOn(int[] bits,
                              int whichBit)

nextBit

public int nextBit(int startBit,
                   boolean on)
returns the next bit, starting a startBit, that has the same value as "on"


anyBitsOn

public boolean anyBitsOn()

firstBitOn

public int firstBitOn()

oneBitOn

public boolean oneBitOn(MesquiteInteger single)
Returns true iff exactly one bit is on. If one bit is on, it returns in "single" the single bit that is on.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getListOfBitsOn

public java.lang.String getListOfBitsOn(int offset)
returns a string listing the bits on. In the format of NEXUS character, taxa lists (e.g., "1- 3 6 201-455". The offset is what the first element is to be numbered (e.g., 0 or 1)


moveColumns

public static void moveColumns(boolean[][] d,
                               int starting,
                               int num,
                               int justAfter)

swapColumns

public static void swapColumns(boolean[][] d,
                               int first,
                               int second)

moveRows

public static void moveRows(boolean[][] d,
                            int starting,
                            int num,
                            int justAfter)

addRows

public static boolean[][] addRows(boolean[][] d,
                                  int starting,
                                  int num)

deleteRows

public static boolean[][] deleteRows(boolean[][] d,
                                     int starting,
                                     int num)

addParts

public static boolean[] addParts(boolean[] d,
                                 int starting,
                                 int num)
Inserts num (cleared) bits just after bit "starting"


deleteParts

public static boolean[] deleteParts(boolean[] values,
                                    int starting,
                                    int num)

reverseBooleanArray

public static boolean[] reverseBooleanArray(boolean[] d)
Reverses the elements of a boolean array


toString

public static java.lang.String toString(int[] bits)

toString

public static java.lang.String toString(boolean[] bits)

toString

public static java.lang.String toString(byte s)
converts passed int to string, as its bits representation. Used for development/debugging. �


toString

public static java.lang.String toString(short s)
converts passed int to string, as its bits representation. Used for development/debugging. �


toString

public static java.lang.String toString(int s)
converts passed int to string, as its bits representation. Used for development/debugging. �


toString

public static java.lang.String toString(long s)
converts passed long to string, as its bits representation. Used for development/debugging. �