A BitSet to replace java.util.BitSet.
Primary differences are that most set operators return new sets
as opposed to oring and anding "in place". Further, a number of
operations were added. I cannot contain a BitSet because there
is no way to access the internal bits (which I need for speed)
and, because it is final, I cannot subclass to add functionality.
Consider defining set degree. Without access to the bits, I must
call a method n times to test the ith bit...ack!
Also seems like or() from util is wrong when size of incoming set is bigger
than this.bits.length.
add
public void add(int el)
or this element into this set (grow as necessary to accommodate)
andInPlace
public void andInPlace(BitSet a)
clear
public void clear(int el)
clone
public Object clone()
degree
public int degree()
equals
public boolean equals(Object obj)
code "inherited" from java.util.BitSet
getRanges
public static Vector getRanges(int[] elems)
Find ranges in a set element array. @param elems The array of
elements representing the set, usually from Bit Set.toArray().
growToInclude
public void growToInclude(int bit)
Grows the set to a larger number of bits.
bit
- element that must fit in set
lengthInLongWords
public int lengthInLongWords()
return how much space is being used by the bits array not
how many actually have member bits on.
member
public boolean member(int el)
notInPlace
public void notInPlace()
notInPlace
public void notInPlace(int maxBit)
complement bits in the range 0..maxBit.
notInPlace
public void notInPlace(int minBit,
int maxBit)
complement bits in the range minBit..maxBit.
of
public static BitSet of(int el)
orInPlace
public void orInPlace(BitSet a)
remove
public void remove(int el)
subset
public boolean subset(BitSet a)
Is this contained within a?
subtractInPlace
public void subtractInPlace(BitSet a)
Subtract the elements of 'a' from 'this' in-place.
Basically, just turn off all bits of 'this' that are in 'a'.
toArray
public int[] toArray()
toPackedArray
public long[] toPackedArray()
toString
public String toString()
toString
public String toString(String separator)
Transform a bit set into a string by formatting each element as an integer
- A commma-separated list of values
toString
public String toString(String separator,
CharFormatter formatter)
Transform a bit set into a string of characters.
formatter
- An object implementing the CharFormatter interface.
- A commma-separated list of character constants.
toString
public String toString(String separator,
Vector vocabulary)
Create a string representation where instead of integer elements, the
ith element of vocabulary is displayed instead. Vocabulary is a Vector
of Strings.
- A commma-separated list of character constants.
toStringOfHalfWords
public String toStringOfHalfWords()
Dump a comma-separated list of the words making up the bit set.
Split each 64 bit number into two more manageable 32 bit numbers.
This generates a comma-separated list of C++-like unsigned long constants.
toStringOfWords
public String toStringOfWords()
Dump a comma-separated list of the words making up the bit set.
This generates a comma-separated list of Java-like long int constants.
toStringWithRanges
public String toStringWithRanges(String separator,
CharFormatter formatter)
Print out the bit set but collapse char ranges.