|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--edu.virginia.cs.mng.hypercast.HC.HC_LogicalAddress
This class includes all the functions related with logical address
Functionality:
It provides the logical address for a hypercube node.
It includes all operations which one might need to do regarding
a Logical address. This would include,
1. Converting from Gray to Colex and vice-versa
2. Printing the Logical Address
3. Find parent of a node with respect to a root
4. Finding neighbor information
| Field Summary | |
private int[] |
BitToOrdered
Permutation required to turn a neighborhood sorted by the bit flipped in the Gray index into a neighborhood table sorted by the Colex index. |
private int |
ColexIndex
The index of this node in the hypercube or HC_Node.MaxAddress() if unvalid. |
private int |
GrayIndex
The gray code encoding of ColexIndex |
private int[] |
OrderedToBit
Permutation required to turn a neighborhood sorted by Colex index into a neighborhood table sorted by the bit flipped in the Gray index. |
private boolean |
OrderingDone
True if bitToOrdered and OrderedToBit have been set. |
| Constructor Summary | |
HC_LogicalAddress(HC_LogicalAddress laddr)
Constructs a new HC_LogicalAddress object from another HC_LogicalAddress |
|
HC_LogicalAddress(int index,
boolean iscolex)
Constructs HC_LogicalAddress object from an Gray index or Colex index Algorithm: If the second argument is true, the integer is the colex ordering, and the gray ordering is trivial to find from the colex ordering, using the the formula (colex XOR (colex/2)) If the second argument is false, and the integer is a gray index, the reverse conversion is a bit more difficult, and is explained in greater detail in the tech report The SortedNeighborhood variable is set to false |
|
| Method Summary | |
HC_LogicalAddress[] |
children(HC_LogicalAddress root,
HC_LogicalAddress hroot)
Gets the children of this node Algorithm: 1. |
private int |
convertGrayToColex(int index)
Converts Gray index to Colex index |
boolean |
equals(HC_LogicalAddress hcla)
Check the equality of two HC_LogicalAddress objects Algorithm: Compares the GrayIndex of both nodes, and the ColexIndex of both. |
boolean |
equals(java.lang.Object o)
Implements Object.equals(Object) as required by I_Address. |
int |
findNeighborIndex(HC_LogicalAddress laddr)
Finds the colex index of a neighbor with a specified logical address. |
private HC_LogicalAddress |
flipNthBit(int i)
Flip the Nth bit of the gray code. |
int |
getColexIndex()
Gets the colex index |
int |
getGrayIndex()
Gets the gray index |
HC_LogicalAddress |
getNthNeighbor(int index)
Gets the Nth Neighbor's logical address Algorithm: 1. |
int |
getSize()
Returns the size of the byte array of this HC_LogicalAddress |
boolean |
greaterThan(I_Address laddr)
Compares two HC_LogicalAddress objects Algorithm: Compares the ColexIndex of both nodes |
private void |
orderNeighborhood()
Initializes the values of OrderedToBit and
BitToOrdered. |
HC_LogicalAddress |
parent(HC_LogicalAddress root)
Gets the Parent of this node Algorithm: 1. |
byte[] |
toByteArray()
Returns the byte array |
java.lang.String |
toString()
Converts logical address object to String |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private int ColexIndex
private int GrayIndex
ColexIndexprivate boolean OrderingDone
bitToOrdered and OrderedToBit have been set.private int[] BitToOrdered
private int[] OrderedToBit
| Constructor Detail |
public HC_LogicalAddress(int index,
boolean iscolex)
Algorithm:
If the second argument is true, the integer is the colex ordering, and
the gray ordering is trivial to find from the colex ordering, using the
the formula (colex XOR (colex/2))
If the second argument is false, and the integer is a gray index, the
reverse conversion is a bit more difficult, and is explained in greater
detail in the tech report
The SortedNeighborhood variable is set to false
index - An Integer which can represent the nodes gray index or
colex indexiscolex - a boolean to indicate if the first argument is
colex or a gray indexpublic HC_LogicalAddress(HC_LogicalAddress laddr)
laddr - An object of type HC_LogicalAddress| Method Detail |
private int convertGrayToColex(int index)
index - An integer which is supposed to represent the GrayIndexprivate void orderNeighborhood()
OrderedToBit and
BitToOrdered.private HC_LogicalAddress flipNthBit(int i)
Algorithm: Takes the GrayIndex of the node itself, and flips the bit at which the neighbor differs from the node. It then builds the logical address of the neighbor using the appropriate constructor.
i - The bit in which the neighbor differs from the node.
The nodes are numbered from 0 to 31public HC_LogicalAddress getNthNeighbor(int index)
Algorithm:
1. Create the ordering if it is not created, by calling orderNeighborhood
2. Find the bit in which the required neighbor differs and then XOR
that bit in GrayIndex, and create a new HC_LogicalAddress.
index - The index of the neighbor, where all neighbors are ordered
by the colex numberpublic int findNeighborIndex(HC_LogicalAddress laddr)
laddr - HC_LogicalAddress of a nodepublic HC_LogicalAddress parent(HC_LogicalAddress root)
Algorithm:
1. Compare the ColexIndex of the node with that of the root
2. If ColexIndex of the node is less than that of the root, flip
the least bit of difference
3. If the situation is otherwise, then flip the greatest bit of
difference
root - Takes as argument the HC_LogicalAddress object of the node which
will be the root of the tree against which you want to find
this nodes parent
public HC_LogicalAddress[] children(HC_LogicalAddress root,
HC_LogicalAddress hroot)
Algorithm:
1. Compare the ColexIndex of the node with that of the root
2. If ColexIndex of the node is less than that of the root, flip
the least bit of difference
3. If the situation is otherwise, then flip the greatest bit of
difference
root - the HC_LogicalAddress object of the node which
will be the root of the treehroot - the HC_LogicalAddress object of the HRoot of the Hypercubepublic int getColexIndex()
public int getGrayIndex()
public boolean equals(HC_LogicalAddress hcla)
Algorithm:
Compares the GrayIndex of both nodes, and the ColexIndex of both.
If both pairs match, return true. If both pairs don't match return false
If however, only one of the pairs matches, there is an inconsistency,
So it exits.
laddr - HC_LogicalAddress object against which testing is to be donepublic boolean equals(java.lang.Object o)
public boolean greaterThan(I_Address laddr)
Algorithm:
Compares the ColexIndex of both nodes
laddr - HC_LogicalAddress object against which testing is to be donepublic byte[] toByteArray()
public int getSize()
public java.lang.String toString()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||