Package org.jmol.util
Class BSUtil
- java.lang.Object
-
- org.jmol.util.BSUtil
-
public final class BSUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description BSUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BS
andNot(BS a, BS b)
static boolean
areEqual(BS a, BS b)
static int
cardinalityOf(BS bs)
cardinality = "total number of set bits"static BS
copy(BS bs)
static BS
copy2(BS a, BS b)
static BS
copyInvert(BS bs, int n)
static BS
deleteBits(BS bs, BS bsDelete)
this one slides deleted bits out of a pattern.static boolean
haveCommon(BS a, BS b)
static BS
invertInPlace(BS bs, int n)
inverts the bitset bits 0 through n-1, and returns a reference to the modified bitsetstatic BS
newAndSetBit(int i)
static BS
newBitSet2(int i0, int i1)
static void
offset(BS bs0, int pos, int offset)
offset the bitset in place by the specified number of bits starting at a given positionstatic BS
setAll(int n)
static void
setMapBitSet(java.util.Map<java.lang.String,BS> ht, int i1, int i2, java.lang.String key)
static void
shiftBits(BS bs, BS bsAdded, boolean setIfFound, int iLast)
this one slides bits to higher positions based on a pattern.static BS
toggleInPlace(BS a, BS 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.
-
-
-
Field Detail
-
emptySet
public static final BS emptySet
-
-
Method Detail
-
newAndSetBit
public static BS newAndSetBit(int i)
-
cardinalityOf
public static int cardinalityOf(BS bs)
cardinality = "total number of set bits"- Parameters:
bs
-- Returns:
- number of set bits
-
newBitSet2
public static BS newBitSet2(int i0, int i1)
-
setAll
public static BS setAll(int n)
-
invertInPlace
public static BS invertInPlace(BS 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 BS toggleInPlace(BS a, BS 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 BS deleteBits(BS bs, BS 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
-
shiftBits
public static void shiftBits(BS bs, BS bsAdded, boolean setIfFound, int iLast)
this one slides bits to higher positions based on a pattern. shiftBits 101011b, 000011b --> 10101100b- Parameters:
bs
-bsAdded
-setIfFound
-iLast
-
-
offset
public static void offset(BS bs0, int pos, int offset)
offset the bitset in place by the specified number of bits starting at a given position- Parameters:
bs0
-pos
- starting position; no change before thisoffset
-
-
setMapBitSet
public static void setMapBitSet(java.util.Map<java.lang.String,BS> ht, int i1, int i2, java.lang.String key)
-
-