|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.commonapi.Id
planet.chord.ChordId
Spedific Chord Id implementation.
Field Summary | |
protected static int |
bitsKey
Sets the number of bits used in last building of MAX. |
protected int |
bitsPerKey
The number of bits per key as is shown in the current configuration. |
protected static Id |
MAX
Maximum value for the ChordId implementation. |
protected static int |
MAX_ARRAY_SIZE
Chord specific constant: Maximum size of array that contains entire identification. |
static int |
MAX_BITS
Chord specific constant: Maximum number of bits for any Id. |
static int |
MIN_BITS
Chord specific constant: Number of bits saved at any array position. |
protected static int |
MODULE
Chord specific constant: Each array position contains a maximum representation of MODULE bits. |
static int[] |
ONE_CHORD
Chord specific constant: The value of one (1) of internal value of Id. |
static int[] |
TWO_CHORD
Chord specific constant: The value of two (2) of internal value of Id. |
Constructor Summary | |
ChordId()
Generates an Id initialized to zero. |
Method Summary | |
Id |
add(Id offset)
Returns an Id corresponding to this Id plus a given offset |
boolean |
between(Id ccw,
Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle |
void |
blit(byte[] target)
|
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()
|
static Id |
divide(int numberOfNodes)
Divides the maximum domain of the node Id in numberOfNodes, to offers the offset between two consecutive nodes. |
Id |
divideOn(int divisor)
This method returns the arithmetical result of this division: thisId/divisor |
boolean |
equals(java.lang.Object obj)
|
int |
getDigit(int i,
int b)
Gets the ith digit in base 2^b. i = 0 is the least significant digit. |
static Id |
getMaximum()
This method returns the maximum value for a ChordId that is possible to build, according the number of bits for key actually in use. |
java.lang.Object |
getValue()
Return the int[] with the value of this Id. |
int |
hashCode()
Hash codes for Ids. |
protected void |
parseBigInteger(java.math.BigInteger value)
Translate the BigInteger value to an Id, partitioning it to fragments of 32 bits. |
void |
setValue(java.lang.Object newValue)
Sets the new value with the int[] that appears at newValue. |
Id |
setValues(java.math.BigInteger newValue)
Sets the internal int[] value from the BigInteger newValue. |
Id |
setValues(byte[] newValue)
Sets the internal int[] value from the byte[] newValue. |
Id |
setValues(double newValue)
Always throws a NoSuchMethodError. |
Id |
setValues(int newValue)
Sets the newValue to the first position of the internal int[], and the rest of positions to zero. |
Id |
setValues(int[] newValue)
Sets the internal value from the int[] newValue |
Id |
setValues(java.util.Random valueGenerator)
Uses the valueGenerator to radomly build a new value. |
Id |
setValues(java.lang.String newValue)
Copies the string representation of a number to the internal int[]. |
Id |
shift(int cnt,
int fill)
Shift operator. shift(-1,0) multiplies value of this by two, shift(1,0) divides by 2 |
Id |
shift(int cnt,
int fill,
boolean roundUp)
Shift operator. shift(-1,0) multiplies value of this by two, shift(1,0) divides by 2 |
Id |
subtract(Id offset)
Returns an Id corresponding to this Id minus a given distance |
Id |
subtractWithCarry(Id offset)
|
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 a string representing the full length of this Id. |
java.lang.String |
toStringHexFull()
Returns the complete represntation of this Id, in hex. |
Methods inherited from class planet.commonapi.Id |
betweenE, Ebetween, setValue, setValues |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int MAX_BITS
public static final int MIN_BITS
public static final int[] ONE_CHORD
public static final int[] TWO_CHORD
protected static final int MODULE
protected static final int MAX_ARRAY_SIZE
protected static int bitsKey
protected static Id MAX
protected int bitsPerKey
Constructor Detail |
public ChordId()
Method Detail |
protected void parseBigInteger(java.math.BigInteger value)
public Id add(Id offset)
add
in class Id
offset
- the offset to add
public Id subtractWithCarry(Id offset)
public Id subtract(Id offset)
Id
subtract
in class Id
offset
- the distance to subtract
public boolean equals(java.lang.Object obj)
public void blit(byte[] target)
public byte[] copy()
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
obj
- the Id to compare with.
public byte[] toByteArray()
toByteArray
in class Id
public int hashCode()
public java.lang.String toStringHexFull()
public java.lang.String toStringFull()
Id
toStringFull
in class Id
public java.lang.String toString()
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 shift(int cnt, int fill)
shift
in class Id
cnt
- the number of bits to shift, negative shifts left, positive shifts rightfill
- value of bit shifted in (0 if fill == 0, 1 otherwise)
public Id shift(int cnt, int fill, boolean roundUp)
cnt
- the number of bits to shift, negative shifts left, positive shifts rightfill
- value of bit shifted in (0 if fill == 0, 1 otherwise)roundUp
- if true, round up the results after right shifting
public boolean between(Id ccw, Id cw)
Id
between
in class Id
ccw
- the counterclockwise idcw
- the clockwise id
public boolean clockwise(Id nid)
clockwise
in class Id
nid
- The Id we are comparing to
public java.lang.Object getValue()
getValue
in class Id
Id.getValue()
public void setValue(java.lang.Object newValue)
setValue
in class Id
newValue
- New value as int[] representation.Id.setValue(java.lang.Object)
public static Id getMaximum()
Id.getMaximum()
public static Id divide(int numberOfNodes)
numberOfNodes
- Number of nodes in the network.
Id.divide(int)
public Id divideOn(int divisor)
divideOn
in class Id
divisor
- The number of parts to divide this Id.
public Id setValues(java.math.BigInteger newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(java.math.BigInteger)
public Id setValues(byte[] newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(byte[])
public Id setValues(double newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(double)
public Id setValues(int newValue)
setValues
in class Id
newValue
- The new value.
Id.setValues(int)
public Id setValues(int[] newValue)
setValues
in class Id
newValue
- The new value
Id.setValues(int[])
public Id setValues(java.util.Random valueGenerator)
setValues
in class Id
valueGenerator
- A Random number generator.
Id.setValues(java.util.Random)
public Id setValues(java.lang.String newValue)
setValues
in class Id
newValue
- The new value.
Id.setValues(java.lang.String)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |