| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectai.krr.propositions.IntEncoding
public class IntEncoding
 This class can be used to encode propositional symbols as integers, which
 have the potential of being processed far more efficiently. A positive
 Literal +P will be encoded as a positive integer n, its
 complement -P as the negative integer -n. Thus two
 encoded Literals are complementary if their absolute value is the same. Note
 that this also means that no Literal will ever be encoded as zero.
 
| Field Summary | |
|---|---|
protected  NamedSymbol[] | 
decode
 | 
protected  int[] | 
encInts
 | 
protected  NamedSymbol[] | 
props
arrays of symbols and encodings (hashed) and decoding:  | 
| Constructor Summary | |
|---|---|
IntEncoding(int capacity)
This constructor creates a new, empty IntEncoding that has an initial capacity for encoding up to the given number of Literals.  | 
|
| Method Summary | |
|---|---|
protected  java.lang.Object | 
clone()
This class does not support cloning and an exception will be thrown if this method is called.  | 
 Literal | 
decode(int enci)
This function can be used to decode the given integer, which must have been the result of a previous encoding.  | 
 int | 
encode(Literal lit)
This function encodes the given Literal.  | 
 int | 
nrEncoded()
This function returns the number of Symbols currently encoded.  | 
 java.lang.String | 
toString()
This function creates a String representation of this IntEncoding.  | 
| Methods inherited from class java.lang.Object | 
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected NamedSymbol[] props
protected int[] encInts
protected NamedSymbol[] decode
| Constructor Detail | 
|---|
public IntEncoding(int capacity)
This constructor creates a new, empty IntEncoding that has an initial capacity for encoding up to the given number of Literals. If this number will be exceeded a rehashing needs to be performed.
capacity - the initial capacity of this IntEncoding| Method Detail | 
|---|
protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
This class does not support cloning and an exception will be thrown if this method is called.
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - will be thrownpublic int encode(Literal lit)
 This function encodes the given Literal. The returned integer uniquely
 identifies the given Literal. A positive Literal +P will be
 encoded as a positive integer n, its complement -P as
 the negative integer -n. Thus two encoded Literals are
 complementary if their absolute value is the same. This function never
 returns zero. Assuming a perfect hash-value for NamedSymbols, encodings
 should be computed in constant time, unless rehashing is necessary.
 
lit - the Literal to be encoded as an integer
public Literal decode(int enci)
This function can be used to decode the given integer, which must have been the result of a previous encoding. The given value must not be zero and its absolute value should be less or equal to the number of Symbols encoded here.
the - integer to be decoded
public int nrEncoded()
This function returns the number of Symbols currently encoded. Note that the number of Literals encoded can be up to twice the returned value.
public java.lang.String toString()
This function creates a String representation of this IntEncoding.
toString in class java.lang.Object
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||