peersim.pastry
Class RoutingTable

java.lang.Object
  extended by peersim.pastry.RoutingTable
All Implemented Interfaces:
java.lang.Cloneable

public class RoutingTable
extends java.lang.Object
implements java.lang.Cloneable


Field Summary
 int cols
           
static java.math.BigInteger EMPTY
          Use this to indicates a entry in the table is not filled
 int rows
           
 java.math.BigInteger[][] table
          all these methods are public in order to provide the fastest possible access
 
Constructor Summary
RoutingTable(int rows, int cols)
          instanciates a new empty routing table with the specified size
 
Method Summary
 java.math.BigInteger accessItem(int prefixlen, char nextChar)
          Provide direct access to the item of the MSPastry routing table, by selecting the associated entry o fthe table with the given prefix length and the given next cipher
 java.lang.Object clone()
           
 void copyRowFrom(RoutingTable otherRT, int i)
           
 java.math.BigInteger get(int rows, int cols)
           
 boolean removeNodeId(java.math.BigInteger b)
          Given a non-null Node Id, it will be removed from the table.
 void set(int row, int column, java.math.BigInteger value)
           
 java.lang.String toString()
          print a string representation of the table
 java.lang.String toString(java.math.BigInteger nodeId)
           
static java.lang.String truncateNodeId(java.math.BigInteger b)
          given a NodeId value, it returns an hexadecimal representation and truncate it on the 4th cipher, for instance truncateNodeId(new BigInteger(0xABCDEF0123)) returns "abcd-".
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final java.math.BigInteger EMPTY
Use this to indicates a entry in the table is not filled


table

public java.math.BigInteger[][] table
all these methods are public in order to provide the fastest possible access


rows

public int rows

cols

public int cols
Constructor Detail

RoutingTable

public RoutingTable(int rows,
                    int cols)
instanciates a new empty routing table with the specified size

Parameters:
rows - int
cols - int
Method Detail

get

public java.math.BigInteger get(int rows,
                                int cols)

set

public void set(int row,
                int column,
                java.math.BigInteger value)

accessItem

public java.math.BigInteger accessItem(int prefixlen,
                                       char nextChar)
Provide direct access to the item of the MSPastry routing table, by selecting the associated entry o fthe table with the given prefix length and the given next cipher

Parameters:
prefixlen - int
nextChar - char
Returns:
long

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

copyRowFrom

public void copyRowFrom(RoutingTable otherRT,
                        int i)

removeNodeId

public boolean removeNodeId(java.math.BigInteger b)
Given a non-null Node Id, it will be removed from the table.

Parameters:
b - BigInteger node to remove from the routing table. if null is specified this method does nothing
Returns:
boolean true is the node was in the table (and then correctly removed), false if the node is not in the table. in both cases the node is removed from the table.

truncateNodeId

public static final java.lang.String truncateNodeId(java.math.BigInteger b)
given a NodeId value, it returns an hexadecimal representation and truncate it on the 4th cipher, for instance truncateNodeId(new BigInteger(0xABCDEF0123)) returns "abcd-". This utility was thought only for debug purpose

Parameters:
b - BigInteger
Returns:
String

toString

public java.lang.String toString(java.math.BigInteger nodeId)

toString

public java.lang.String toString()
print a string representation of the table

Overrides:
toString in class java.lang.Object
Returns:
String