|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--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
Constructor Summary | |
HC_LogicalAddress(byte[] byteAddr,
int offset)
Constructs HC_LogicalAddress object from an byte array using Colex index Algorithm: |
|
HC_LogicalAddress(hypercast.HC.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 |
|
HC_LogicalAddress(java.lang.String addr)
added by Guangyu May 02, 04 |
Method Summary | |
hypercast.HC.HC_LogicalAddress[] |
children(hypercast.HC.HC_LogicalAddress root,
hypercast.HC.HC_LogicalAddress hroot)
Gets the children of this node |
boolean |
equals(hypercast.HC.HC_LogicalAddress hcla)
Check the equality of two HC_LogicalAddress objects |
boolean |
equals(java.lang.Object o)
Implements Object.equals(Object) as required by I_Address. |
int |
findNeighborIndex(hypercast.HC.HC_LogicalAddress laddr)
Finds the colex index of a neighbor with a specified logical address. |
int |
getColexIndex()
Gets the colex index |
int |
getGrayIndex()
Gets the gray index |
hypercast.HC.HC_LogicalAddress |
getNthNeighbor(int index)
Gets the Nth Neighbor's logical address |
int |
getSize()
Returns the size of the byte array of this HC_LogicalAddress |
boolean |
greaterThan(hypercast.I_Address laddr)
Compares two HC_LogicalAddress objects |
hypercast.HC.HC_LogicalAddress |
parent(hypercast.HC.HC_LogicalAddress root)
Gets the Parent of this node |
byte[] |
toByteArray()
Returns the byte array |
java.lang.String |
toString()
Converts logical address object to String |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface hypercast.I_Address |
hashCode |
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(java.lang.String addr)
public HC_LogicalAddress(byte[] byteAddr, int offset)
byteAddr
- a bytearray containing the Colex index.offset
- the start position of index in the byte array.public HC_LogicalAddress(hypercast.HC.HC_LogicalAddress laddr)
laddr
- An object of type HC_LogicalAddressMethod Detail |
public hypercast.HC.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 number
No
- formal Exceptions raised; however, it ArrayBoundsException
will be raised by the system if index is out of boundspublic int findNeighborIndex(hypercast.HC.HC_LogicalAddress laddr)
laddr
- HC_LogicalAddress of a node
public hypercast.HC.HC_LogicalAddress parent(hypercast.HC.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
Exits,
- if the node itself is passed as a rootpublic hypercast.HC.HC_LogicalAddress[] children(hypercast.HC.HC_LogicalAddress root, hypercast.HC.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 Hypercube
Exits,
- if the node itself is passed as a rootpublic int getColexIndex()
public int getGrayIndex()
public boolean equals(hypercast.HC.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.
hcla
- HC_LogicalAddress object against which testing is to be done
No
- formal exceptions; however it exits if it finds an inconsistencypublic boolean equals(java.lang.Object o)
equals
in interface I_Address
equals
in class java.lang.Object
public boolean greaterThan(hypercast.I_Address laddr)
Algorithm:
Compares the ColexIndex of both nodes
greaterThan
in interface I_Address
laddr
- HC_LogicalAddress object against which testing is to be done
public byte[] toByteArray()
toByteArray
in interface I_Address
public int getSize()
getSize
in interface I_Address
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |