public final class SerialArithmeticNumber extends Object
[RFC 1982], with SERIAL_BITS = 32.
Unlike the original algorithm, this implementation is based on unsigned subtraction, resolving the issue of undefined
comparisons, however introducing one additional oddity - each member of a pair of serial numbers with a wrapped
distance of 2^(SERIAL_BITS - 1) will be considered less than (and greater than) the other one.
| Constructor and Description |
|---|
SerialArithmeticNumber()
Creates a new
SerialArithmeticNumber with a starting value of zero. |
SerialArithmeticNumber(int value)
Creates a new
SerialArithmeticNumber with the specified starting value. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(int serialArithmeticNumber)
|
int |
getValue()
Returns the
SerialArithmeticNumber's value. |
boolean |
greaterThan(int serialArithmeticNumber)
Returns
true if the parameter is greater than the value in serial number arithmetics and
false if it is not. |
void |
increment()
Increments the
SerialArithmeticNumber's value by one. |
boolean |
lessThan(int serialArithmeticNumber)
Returns
true if the parameter is less than the value in serial number arithmetics and
false if it is not. |
public SerialArithmeticNumber()
SerialArithmeticNumber with a starting value of zero.public SerialArithmeticNumber(int value)
SerialArithmeticNumber with the specified starting value.value - the initial valuepublic void increment()
SerialArithmeticNumber's value by one.public boolean equals(int serialArithmeticNumber)
serialArithmeticNumber - the serial arithmetic number to matchtrue if the parameter matches the value and false if it does notpublic boolean lessThan(int serialArithmeticNumber)
true if the parameter is less than the value in serial number arithmetics and
false if it is not.serialArithmeticNumber - the serial arithmetic number to matchtrue if the parameter is less than the value in serial number arithmetics and
false if it is notpublic boolean greaterThan(int serialArithmeticNumber)
true if the parameter is greater than the value in serial number arithmetics and
false if it is not.serialArithmeticNumber - the serial arithmetic number to matchtrue if the parameter is greater than the value in serial number arithmetics and
false if it is notpublic int getValue()
SerialArithmeticNumber's value.valueCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.