|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectrice.pastry.Id
Represents a Pastry identifier for a node, object or key. A single identifier and the bit length for Ids is stored in this class. Ids are stored little endian.
| Nested Class Summary | |
static class |
Id.Distance
A class for representing and manipulating the distance between two Ids on the circle. |
| Field Summary | |
static int[] |
Half
|
static int |
IdBitLength
This is the bit length of the node ids. |
static int[] |
NegOne
|
static int[] |
Null
|
static int[] |
One
|
| Constructor Summary | |
Id()
Constructor. |
|
Id(byte[] material)
Constructor. |
|
Id(int[] material)
Constructor. |
|
| Method Summary | |
Id |
add(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance |
Id |
addToId(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance |
void |
blit(byte[] target)
Blits the Id into a target array. |
boolean |
checkBit(int i)
Checks if the ith bit is flipped. |
boolean |
clockwise(Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. |
boolean |
clockwise(Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. |
int |
compareTo(java.lang.Object obj)
Comparison operator for Ids. |
byte[] |
copy()
Copy the Id into a freshly generated array. |
Id.Distance |
distance(Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids. |
Id.Distance |
distanceFromId(Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids. |
boolean |
equals(Id nid)
Equivalence relation for Ids. |
boolean |
equals(java.lang.Object obj)
Equality operator for Ids. |
Id |
getAlternateId(int num,
int b,
int i)
produces a set of ids (keys) that are evenly distributed around the id ring. |
Id |
getCCW()
gets the Id just counterclockwise from this |
Id |
getCW()
gets the Id just clockwise from this |
int |
getDigit(int i,
int b)
Gets the ith digit in base 2^b. |
Id |
getDomainPrefix(int row,
int column,
int suffixDigit,
int b)
produces a Id whose prefix up to row is identical to this, followed by a digit with value column, followed by a suffix of digits with value suffixDigits. |
int |
hashCode()
Hash codes for Ids. |
int |
indexOfMSDB(Id nid)
Returns the index of the most significant differing bit (MSDB). |
int |
indexOfMSDD(Id nid,
int base)
Returns the index of the most significant different digit (MSDD) in a given base. |
boolean |
isBetween(Id ccw,
Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
boolean |
isBetween(Id ccw,
Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
Id.Distance |
longDistance(Id nid)
Returns the longer numerical distance on the ring between a pair of Ids. |
Id.Distance |
longDistanceFromId(Id nid)
Returns the longer numerical distance on the ring between a pair of Ids. |
static Id |
makeRandomId(java.util.Random rng)
Creates a random Id. |
static int |
numDigits(int base)
return the number of digits in a given base |
void |
setBit(int i,
int v)
Sets the ith bit to a given value i = 0 is the least significant bit. |
void |
setDigit(int i,
int v,
int b)
Sets the ith digit in base 2^b. |
byte[] |
toByteArray()
Returns the byte array representation of this Id |
java.lang.String |
toString()
Returns a string representation of the Id in base 16. |
java.lang.String |
toStringFull()
Returns the complete represntation of this Id, in hex. |
void |
xor(Id otherId)
Xor operator for Ids. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int[] Null
public static final int[] One
public static final int[] NegOne
public static final int[] Half
public static final int IdBitLength
| Constructor Detail |
public Id(byte[] material)
material - an array of length at least IdBitLength/8 containing raw Id material.public Id(int[] material)
material - an array of length at least IdBitLength/32 containing raw Id material.public Id()
| Method Detail |
public static int numDigits(int base)
base - the number of bits in the base
public static Id makeRandomId(java.util.Random rng)
rng - random number generator
public Id getCW()
public Id getCCW()
public boolean isBetween(Id ccw,
Id cw)
ccw - the counterclockwise idcw - the clockwise id
public int getDigit(int i,
int b)
i - which digit to get.b - which power of 2 is the base to get it in.
public Id getDomainPrefix(int row,
int column,
int suffixDigit,
int b)
row - the length of the prefixcolumn - the value of the following digitsuffixDigit - the value of the suffix digitsb - power of 2 of the base
public Id getAlternateId(int num,
int b,
int i)
num - the number of Ids in the set (must be <= 2^b)b - the routing base (as a power of 2)i - the index of the requested member of the set (0<=i
public boolean isBetween(Id ccw,
Id cw)
isBetween in interface Idccw - the counterclockwise idcw - the clockwise id
public void setBit(int i,
int v)
i - which bit to set.v - new value of bit
public void setDigit(int i,
int v,
int b)
i - which digit to get.v - the new value of the digitb - which power of 2 is the base to get it in.public void blit(byte[] target)
target - an array of length at least IdBitLength/8 for the Id to be stored in.public byte[] copy()
public boolean equals(java.lang.Object obj)
obj - a Id object
public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparableobj - the Id to compare with.
public byte[] toByteArray()
toByteArray in interface Idpublic int hashCode()
public Id add(Id.Distance offset)
offset - the distance to add
public Id.Distance distance(Id nid)
nid - the other node id.
public Id.Distance longDistance(Id nid)
nid - the other node id.
public void xor(Id otherId)
otherId - a Id objectpublic boolean equals(Id nid)
nid - the other node id.
public boolean clockwise(Id nid)
nid - The Id we are comparing to
public boolean checkBit(int i)
i - which bit to check.
public int indexOfMSDB(Id nid)
nid - another node id to compare with.
public int indexOfMSDD(Id nid,
int base)
nid - another node id to compare with.base - the base (as a power of two) to compare in.
public java.lang.String toString()
public java.lang.String toStringFull()
toStringFull in interface Idpublic boolean clockwise(Id nid)
clockwise in interface Idnid - DESCRIBE THE PARAMETER
public Id addToId(Id.Distance offset)
addToId in interface Idoffset - the distance to add
public Id.Distance distanceFromId(Id nid)
distanceFromId in interface Idnid - the other node id.
public Id.Distance longDistanceFromId(Id nid)
longDistanceFromId in interface Idnid - the other node id.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||