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.


Constructor Index

 o logic.BooleanTuple(Vector)
The constructor accepts a Vector of Booleans.

Method Index

 o 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.
 o getTuple()
 o hashCode()
The motivation for this method is explained in the comments for hashCode2().
 o 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.
 o setTuple(Boolean[])
 o setTuple(Vector)
 o size()
 o toString()

Constructors

 o 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.

Methods

 o 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
 o getTuple
public java.lang.Boolean[] getTuple()
 o 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
 o 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.

 o setTuple
public void setTuple(Boolean[] arr)
 o setTuple
public void setTuple(Vector v)
 o size
public int size()
 o toString
public java.lang.String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index