org.jmol.util
Class BitSetUtil
java.lang.Object
org.jmol.util.BitSetUtil
public final class BitSetUtil
- extends java.lang.Object
Field Summary |
private static java.util.BitSet |
bsNull
|
Method Summary |
static void |
andNot(java.util.BitSet a,
java.util.BitSet b)
|
static int |
cardinalityOf(java.util.BitSet bs)
cardinality = "total number of set bits" |
static void |
clear(java.util.BitSet bs)
|
static boolean |
compareBits(java.util.BitSet a,
java.util.BitSet b)
|
static java.util.BitSet |
copy(java.util.BitSet bs)
|
static void |
copy(java.util.BitSet a,
java.util.BitSet b)
|
static java.util.BitSet |
copyInvert(java.util.BitSet bs,
int n)
|
static java.util.BitSet |
deleteBits(java.util.BitSet bs,
java.util.BitSet bsDelete)
|
static int |
firstSetBit(java.util.BitSet bs)
|
static boolean |
haveCommon(java.util.BitSet a,
java.util.BitSet b)
|
static java.util.BitSet |
invertInPlace(java.util.BitSet bs,
int n)
inverts the bitset bits 0 through n-1,
and returns a reference to the modified bitset |
static int |
length(java.util.BitSet bs)
length = "last set bit plus one" |
static java.util.BitSet |
setAll(int n)
|
static java.util.BitSet |
toggleInPlace(java.util.BitSet a,
java.util.BitSet b,
int n)
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
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 |
bsNull
private static final java.util.BitSet bsNull
BitSetUtil
public BitSetUtil()
length
public static int length(java.util.BitSet bs)
- length = "last set bit plus one"
- Parameters:
bs
-
- Returns:
- the index of the last set bit
firstSetBit
public static int firstSetBit(java.util.BitSet bs)
cardinalityOf
public static int cardinalityOf(java.util.BitSet bs)
- cardinality = "total number of set bits"
- Parameters:
bs
-
- Returns:
- number of set bits
setAll
public static java.util.BitSet setAll(int n)
andNot
public static void andNot(java.util.BitSet a,
java.util.BitSet b)
copy
public static java.util.BitSet copy(java.util.BitSet bs)
copy
public static void copy(java.util.BitSet a,
java.util.BitSet b)
clear
public static void clear(java.util.BitSet bs)
copyInvert
public static java.util.BitSet copyInvert(java.util.BitSet bs,
int n)
invertInPlace
public static java.util.BitSet invertInPlace(java.util.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 java.util.BitSet toggleInPlace(java.util.BitSet a,
java.util.BitSet b,
int n)
- 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
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
- n
-
- Returns:
- a handy pointer to the working set, a
compareBits
public static boolean compareBits(java.util.BitSet a,
java.util.BitSet b)
haveCommon
public static boolean haveCommon(java.util.BitSet a,
java.util.BitSet b)
deleteBits
public static java.util.BitSet deleteBits(java.util.BitSet bs,
java.util.BitSet bsDelete)