edu.virginia.cs.mng.hypercast.DT
Class DT_LogicalAddress
java.lang.Object
|
+--edu.virginia.cs.mng.hypercast.DT.DT_Point
|
+--edu.virginia.cs.mng.hypercast.DT.DT_LogicalAddress
- final class DT_LogicalAddress
- extends DT_Point
- implements I_LogicalAddress
A logical address on the Delaunay triangulation.
It extends DT_Point.
It is immutable.
|
Field Summary |
static int |
ADDRESS_ARRAY_SIZE
|
private static java.util.Random |
rand
length of byte array required to hold the address |
| Fields inherited from class edu.virginia.cs.mng.hypercast.DT.DT_Point |
x,
y |
|
Method Summary |
private static int |
everyOtherBit(IP_Address a,
boolean evenBits)
This function converts the IP_Address to a long, and
then creates an integer made from every other bit of the IP_Address. |
int |
getSize()
Returns the size of byte[] used to store address. |
boolean |
greaterThan(I_Address a)
Implements method of I_Address interface. |
byte[] |
toByteArray()
Converts the object into a byte array for transfer in a message. |
| Methods inherited from class edu.virginia.cs.mng.hypercast.DT.DT_Point |
angleRelative,
angleToHorizon,
distance,
equals,
findCenterOfCircle,
getX,
getY,
greaterThan,
hashCode,
isInCircle,
isInOrOnCircle,
isOnCircle,
toString |
| Methods inherited from class java.lang.Object |
,
clone,
finalize,
getClass,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
rand
private static final java.util.Random rand
- length of byte array required to hold the address
ADDRESS_ARRAY_SIZE
public static final int ADDRESS_ARRAY_SIZE
DT_LogicalAddress
public DT_LogicalAddress(int xx,
int yy)
- constructor with the coodinates pair
DT_LogicalAddress
public DT_LogicalAddress(DT_LogicalAddress dtla)
DT_LogicalAddress
public DT_LogicalAddress(byte[] array,
int offset)
- Reads coordinates from a byte array.
It reads 8 bytes - the first 4 making the x-coordinate, the last 4 making the y-coordinate.
DT_LogicalAddress
public DT_LogicalAddress(java.lang.String s)
- Reads coordinates from string in format "\d+,\d+". (e.g. "12345,67890")
DT_LogicalAddress
public DT_LogicalAddress(IP_Address a)
- Creates coordinate such that if 2 nodes are on the same network, they have close coordinates.
This is accomplished by taking every even-number bit in the IP_Address to make the x-coordinate,
and every odd-numbered bit to make the y-coordinate.
Note, implication does not go the other way. (i.e. if coordinates are close, it does not mean nodes
are on the same network.)
everyOtherBit
private static int everyOtherBit(IP_Address a,
boolean evenBits)
- This function converts the IP_Address to a long, and
then creates an integer made from every other bit of the IP_Address.
It is called by
DT_LogicalAddress(IP_Address)
greaterThan
public boolean greaterThan(I_Address a)
- Implements method of I_Address interface.
getSize
public int getSize()
- Returns the size of byte[] used to store address.
toByteArray
public byte[] toByteArray()
- Converts the object into a byte array for transfer in a message.
This is the exact inverse of the constructor that takes a byte array.