Rice Pastry API

rice.p2p.commonapi
Interface Id

All Superinterfaces:
java.lang.Comparable, java.io.Serializable
All Known Implementing Classes:
Id

public interface Id
extends java.lang.Comparable, java.io.Serializable

Version:
$Id: Id.java,v 1.7 2003/09/28 08:16:29 amislove Exp $
Author:
Alan Mislove, Peter Druschel

Nested Class Summary
static interface Id.Distance
          A class for representing and manipulating the distance between two Ids on the circle.
 
Method Summary
 rice.p2p.commonapi.Id addToId(Id.Distance offset)
          Returns an Id corresponding to this Id plus a given distance
 boolean clockwise(rice.p2p.commonapi.Id nid)
          Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring.
 Id.Distance distanceFromId(rice.p2p.commonapi.Id nid)
          Returns the shorter numerical distance on the ring between a pair of Ids.
 boolean isBetween(rice.p2p.commonapi.Id ccw, rice.p2p.commonapi.Id cw)
          Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle
 Id.Distance longDistanceFromId(rice.p2p.commonapi.Id nid)
          Returns the longer numerical distance on the ring between a pair of Ids.
 byte[] toByteArray()
          Returns a (mutable) byte array representing this Id
 java.lang.String toStringFull()
          Returns a string representing the full length of this Id.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

isBetween

public boolean isBetween(rice.p2p.commonapi.Id ccw,
                         rice.p2p.commonapi.Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle

Parameters:
ccw - the counterclockwise id
cw - the clockwise id
Returns:
true if this is between ccw (inclusive) and cw (exclusive), false otherwise

clockwise

public boolean clockwise(rice.p2p.commonapi.Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. An Id is clockwise if it is within the half circle clockwise from this on the ring. An Id is considered counter-clockwise from itself.

Parameters:
nid - The id to compare to
Returns:
true if clockwise, false otherwise.

addToId

public rice.p2p.commonapi.Id addToId(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance

Parameters:
offset - the distance to add
Returns:
the new Id

distanceFromId

public Id.Distance distanceFromId(rice.p2p.commonapi.Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids.

Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

longDistanceFromId

public Id.Distance longDistanceFromId(rice.p2p.commonapi.Id nid)
Returns the longer numerical distance on the ring between a pair of Ids.

Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

toByteArray

public byte[] toByteArray()
Returns a (mutable) byte array representing this Id

Returns:
A byte[] representing this Id

toStringFull

public java.lang.String toStringFull()
Returns a string representing the full length of this Id.

Returns:
A string with all of this Id

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection