org.jmol.util
Class BitSetUtil

java.lang.Object
  extended by org.jmol.util.BitSetUtil

public final class BitSetUtil
extends Object


Field Summary
static BitSet bsNull
           
 
Constructor Summary
BitSetUtil()
           
 
Method Summary
static BitSet andNot(BitSet a, BitSet b)
           
static boolean areEqual(BitSet a, BitSet b)
           
static int cardinalityOf(BitSet bs)
          cardinality = "total number of set bits"
static BitSet copy(BitSet bs)
           
static BitSet copy(BitSet a, BitSet b)
           
static BitSet copyInvert(BitSet bs, int n)
           
static BitSet deleteBits(BitSet bs, BitSet bsDelete)
          this one slides deleted bits out of a pattern.
static boolean haveCommon(BitSet a, BitSet b, BitSet bsTemp)
           
static BitSet invertInPlace(BitSet bs, int n)
          inverts the bitset bits 0 through n-1, and returns a reference to the modified bitset
static BitSet newBitSet(int i0, int i1)
           
static BitSet setAll(int n)
           
static BitSet setBit(int i)
           
static BitSet toggleInPlace(BitSet a, BitSet b)
          a perhaps curious method: b is a reference set, perhaps all atoms in a certain molecule a is the working set, perhaps representing all displayed atoms For each set bit in b: a) if a is also set, then clear a's bit UNLESS b) if a is not set, then add to a all set bits of b Thus, if a equals b --> clear all if a is a subset of b, then --> b if b is a subset of a, then --> a not b if a only intersects with b, then --> a or b if a does not intersect with b, then a or b In "toggle" mode, when you click on any atom of the molecule, you want either: (a) all the atoms in the molecule to be displayed if not all are already displayed, or (b) the whole molecule to be hidden if all the atoms of the molecule are already displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bsNull

public static final BitSet bsNull
Constructor Detail

BitSetUtil

public BitSetUtil()
Method Detail

setBit

public static BitSet setBit(int i)

areEqual

public static boolean areEqual(BitSet a,
                               BitSet b)

haveCommon

public static boolean haveCommon(BitSet a,
                                 BitSet b,
                                 BitSet bsTemp)

cardinalityOf

public static int cardinalityOf(BitSet bs)
cardinality = "total number of set bits"

Parameters:
bs -
Returns:
number of set bits

newBitSet

public static BitSet newBitSet(int i0,
                               int i1)

setAll

public static BitSet setAll(int n)

andNot

public static BitSet andNot(BitSet a,
                            BitSet b)

copy

public static BitSet copy(BitSet bs)

copy

public static BitSet copy(BitSet a,
                          BitSet b)

copyInvert

public static BitSet copyInvert(BitSet bs,
                                int n)

invertInPlace

public static BitSet invertInPlace(BitSet bs,
                                   int n)
inverts the bitset bits 0 through n-1, and returns a reference to the modified bitset

Parameters:
bs -
n -
Returns:
pointer to original bitset, now inverted

toggleInPlace

public static BitSet toggleInPlace(BitSet a,
                                   BitSet b)
a perhaps curious method: b is a reference set, perhaps all atoms in a certain molecule a is the working set, perhaps representing all displayed atoms For each set bit in b: a) if a is also set, then clear a's bit UNLESS b) if a is not set, then add to a all set bits of b Thus, if a equals b --> clear all if a is a subset of b, then --> b if b is a subset of a, then --> a not b if a only intersects with b, then --> a or b if a does not intersect with b, then a or b In "toggle" mode, when you click on any atom of the molecule, you want either: (a) all the atoms in the molecule to be displayed if not all are already displayed, or (b) the whole molecule to be hidden if all the atoms of the molecule are already displayed.

Parameters:
a -
b -
Returns:
a handy pointer to the working set, a

deleteBits

public static BitSet deleteBits(BitSet bs,
                                BitSet bsDelete)
this one slides deleted bits out of a pattern. deleteBits 101011b, 000011b --> 1010b Java 1.4, not 1.3

Parameters:
bs -
bsDelete -
Returns:
shorter bitset