Class logic.BooleanTuple
All Packages Class Hierarchy This Package Previous Next Index
Class logic.BooleanTuple
Object
|
+----logic.BooleanTuple
- public class BooleanTuple
- extends Object
This class is a wrapper for an array of Booleans.
We need a wrapper so that it can be used as a key
in a hashtable. It provides a simple implementation of
hashCode() for this purpose.
-
logic.BooleanTuple(Vector)
- The constructor accepts a Vector of Booleans.
-
equals(Object)
- Two BooleanTuples are equal if they are both nonnull, and their
underlying instances of Boolean[] have the same length and
have entries that have the same booleanValue()'s.
-
getTuple()
-
-
hashCode()
- The motivation for this method is explained in the
comments for hashCode2().
-
hashCode2()
- The algorithm used here is to treat a sequence
of booleans as a binary sequence, with T=1 and F=0,
and then treat the binary sequence as an actual
binary integer.
-
setTuple(Boolean[])
-
-
setTuple(Vector)
-
-
size()
-
-
toString()
-
BooleanTuple
public BooleanTuple(Vector tuple) throws PoorPerformanceException
- The constructor accepts a Vector of Booleans. The size of the Vector
is equal to the number of Conditions-- only MAX_LEVELS_OF_NESTING
Conditions are allowed (in the original implementation, this maximum
number is 30). The constuctor converts the Vector to an array
of Booleans and caches it.
equals
public boolean equals(Object ob)
- Two BooleanTuples are equal if they are both nonnull, and their
underlying instances of Boolean[] have the same length and
have entries that have the same booleanValue()'s.
- Overrides:
- equals in class Object
getTuple
public java.lang.Boolean[] getTuple()
hashCode
public int hashCode()
- The motivation for this method is explained in the
comments for hashCode2(). This version is faster
since we avoid using exponentials and make use of the
convenient representation of powers of 2 in hexadecimal notation
- Overrides:
- hashCode in class Object
hashCode2
public int hashCode2()
- The algorithm used here is to treat a sequence
of booleans as a binary sequence, with T=1 and F=0,
and then treat the binary sequence as an actual
binary integer. The algorithm simply computes the
base 10 value of this binary number and returns it.
An inherent limitation is that the largest allowed int
is 2^31 -1, so that we can't rely on the algorithm
for tuples of length > 30.
Note that this version shows the idea, but is slower
than necessary since it relies on exponential function.
The hashCode() function that we use is given below.
setTuple
public void setTuple(Boolean[] arr)
setTuple
public void setTuple(Vector v)
size
public int size()
toString
public java.lang.String toString()
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index