|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeersim.pastry.Util
public class Util
Some utility and mathematical function to work with numbers and strings.
Title: MSPASTRY
Description: MsPastry implementation for PeerSim
Copyright: Copyright (c) 2007
Company: The Pastry Group
Field Summary | |
---|---|
static char[] |
DIGITS
|
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static int |
charToIndex(char c)
convert a cipher in the equivalent int value '0'-->0, ... |
static java.math.BigInteger |
distance(java.math.BigInteger a,
java.math.BigInteger b)
return the distance between two number, that is |a-b|. |
static boolean |
hasDigitAt(java.math.BigInteger b,
int position,
char c)
Given b, normalize it and check if char c is at specified position |
static int |
max(int a,
int b)
max between a and b |
static int |
min(int a,
int b)
min between a and b |
static boolean |
nearer(java.math.BigInteger center,
java.math.BigInteger near,
java.math.BigInteger far)
given a point (center), returns true if the second parameter (near) has less distance from the center respect with the 3rd point (far) |
static int |
pow2(int i)
2^i |
static int |
prefixLen(java.math.BigInteger b1,
java.math.BigInteger b2)
Given two numbers, returns the length of the common prefix, i.e. |
static java.lang.String |
put0(java.math.BigInteger b)
convert a BigInteger into a String, by considering the current BASE, and by leading all needed non-significative zeroes in order to reach the canonical length of a nodeid |
static boolean |
startsWith(java.math.BigInteger b,
char c)
return true if b (normalized) starts with c |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char[] DIGITS
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static final int prefixLen(java.math.BigInteger b1, java.math.BigInteger b2)
b1
- BigIntegerb2
- BigInteger
public static final boolean startsWith(java.math.BigInteger b, char c)
b
- BigIntegerc
- char
public static final java.math.BigInteger distance(java.math.BigInteger a, java.math.BigInteger b)
a
- BigIntegerb
- BigInteger
public static final boolean nearer(java.math.BigInteger center, java.math.BigInteger near, java.math.BigInteger far)
center
- BigIntegernear
- BigIntegerfar
- BigInteger
public static final boolean hasDigitAt(java.math.BigInteger b, int position, char c)
b
- BigIntegerposition
- intc
- char
public static final int max(int a, int b)
a
- intb
- int
public static final int min(int a, int b)
a
- intb
- int
public static final java.lang.String put0(java.math.BigInteger b)
b
- BigInteger
public static final int charToIndex(char c)
c
- char
public static final int pow2(int i)
i
- int i must be a non-negative number
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |