Rice Pastry API

rice.pastry
Class IdRange

java.lang.Object
  |
  +--rice.pastry.IdRange
All Implemented Interfaces:
IdRange, java.io.Serializable

public class IdRange
extends java.lang.Object
implements IdRange, java.io.Serializable

Represents a contiguous range of Pastry ids. *

Version:
$Id: IdRange.java,v 1.17 2003/07/24 11:54:02 amislove Exp $
Author:
Peter Druschel
See Also:
Serialized Form

Constructor Summary
IdRange()
          Constructor, constructs an empty IdRange
IdRange(boolean type)
           
IdRange(rice.pastry.Id ccw, rice.pastry.Id cw)
          Constructor.
IdRange(rice.pastry.IdRange o)
          Copy constructor.
 
Method Summary
 rice.pastry.IdRange ccwHalf()
          get counterclockwise half of the range
 rice.pastry.IdRange complement()
          get the complement of this range on the ring
 boolean contains(rice.pastry.Id key)
          test if a given key lies within this range
 boolean containsId(rice.p2p.commonapi.Id key)
          test if a given key lies within this range
 rice.pastry.IdRange cwHalf()
          get clockwise half of the range
 rice.pastry.IdRange diff(rice.pastry.IdRange o)
          compute the difference between two ranges (exclusive or of keys in the two ranges) two ranges may differ in two ranges on the circle; this method produces one such range of difference if one exists the other range of difference can be computed by invoking o.diff(this)
 boolean equals(java.lang.Object obj)
          equality operator
 rice.pastry.Id getCCW()
          get counterclockwise edge of range
 rice.p2p.commonapi.Id getCCWId()
          get counterclockwise edge of range
 rice.p2p.commonapi.IdRange getComplementRange()
          get the complement of this range
 rice.pastry.Id getCW()
          get clockwise edge of range
 rice.p2p.commonapi.Id getCWId()
          get clockwise edge of range
 rice.pastry.IdRange intersect(rice.pastry.IdRange o)
          intersect two ranges returns an empty range if the ranges don't intersect two ranges may intersect in two ranges on the circle; this method produces one such range of intersection if one exists the other range of intersection can be computed by invoking o.intersect(this)
 boolean isAdjacent(rice.pastry.IdRange o)
          test if this range is adjacent to another range
 boolean isEmpty()
          test if the range is empty
 boolean isFull()
          test if the range is the full circle
 rice.pastry.IdRange merge(rice.pastry.IdRange o)
          merge two ranges if this and other don't overlap, are not adjacent, and this is not empty, then the result is this
 rice.pastry.IdRange subtract(rice.pastry.IdRange o, boolean cwPart)
          subtract the other range from this computes the ranges of keys that are in this but not in o subtracting a range may produce two ranges on the circle; this method produces one such ranges under control of the cwPart parameter
 java.lang.String toString()
          Returns a string representation of the range.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdRange

public IdRange(rice.pastry.Id ccw,
               rice.pastry.Id cw)
Constructor.

Parameters:
ccw - the id at the counterclockwise edge of the range (inclusive)
cw - the id at the clockwise edge of the range (exclusive)

IdRange

public IdRange()
Constructor, constructs an empty IdRange


IdRange

public IdRange(boolean type)

IdRange

public IdRange(rice.pastry.IdRange o)
Copy constructor.

Method Detail

equals

public boolean equals(java.lang.Object obj)
equality operator

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other IdRange
Returns:
true if the IdRanges are equal

isEmpty

public boolean isEmpty()
test if the range is empty

Returns:
true if the range is empty

isFull

public boolean isFull()
test if the range is the full circle

Returns:
true if the range is full circle

isAdjacent

public boolean isAdjacent(rice.pastry.IdRange o)
test if this range is adjacent to another range

Parameters:
o - another range
Returns:
true if the range is asjacent to o

contains

public boolean contains(rice.pastry.Id key)
test if a given key lies within this range

Parameters:
key - the key
Returns:
true if the key lies within this range, false otherwise

getCCW

public rice.pastry.Id getCCW()
get counterclockwise edge of range

Returns:
the id at the counterclockwise edge of the range (inclusive)

getCW

public rice.pastry.Id getCW()
get clockwise edge of range

Returns:
the id at the clockwise edge of the range (exclusive)

merge

public rice.pastry.IdRange merge(rice.pastry.IdRange o)
merge two ranges if this and other don't overlap, are not adjacent, and this is not empty, then the result is this

Parameters:
o - the other range
Returns:
the resulting range

complement

public rice.pastry.IdRange complement()
get the complement of this range on the ring

Returns:
the complement range

intersect

public rice.pastry.IdRange intersect(rice.pastry.IdRange o)
intersect two ranges returns an empty range if the ranges don't intersect two ranges may intersect in two ranges on the circle; this method produces one such range of intersection if one exists the other range of intersection can be computed by invoking o.intersect(this)

Parameters:
o - the other range
Returns:
the result range

diff

public rice.pastry.IdRange diff(rice.pastry.IdRange o)
compute the difference between two ranges (exclusive or of keys in the two ranges) two ranges may differ in two ranges on the circle; this method produces one such range of difference if one exists the other range of difference can be computed by invoking o.diff(this)

Parameters:
o - the other range
Returns:
the result range

subtract

public rice.pastry.IdRange subtract(rice.pastry.IdRange o,
                                    boolean cwPart)
subtract the other range from this computes the ranges of keys that are in this but not in o subtracting a range may produce two ranges on the circle; this method produces one such ranges under control of the cwPart parameter

Parameters:
o - the other range
cwPart - if true, returns the clockwise part of the range subtraction, else the counterclockwise part
Returns:
the result range

ccwHalf

public rice.pastry.IdRange ccwHalf()
get counterclockwise half of the range

Returns:
the range corresponding to the ccw half of this range

cwHalf

public rice.pastry.IdRange cwHalf()
get clockwise half of the range

Returns:
the range corresponding to the cw half of this range

toString

public java.lang.String toString()
Returns a string representation of the range.

Overrides:
toString in class java.lang.Object

containsId

public boolean containsId(rice.p2p.commonapi.Id key)
test if a given key lies within this range

Specified by:
containsId in interface IdRange
Parameters:
key - the key
Returns:
true if the key lies within this range, false otherwise

getCCWId

public rice.p2p.commonapi.Id getCCWId()
get counterclockwise edge of range

Specified by:
getCCWId in interface IdRange
Returns:
the id at the counterclockwise edge of the range (inclusive)

getCWId

public rice.p2p.commonapi.Id getCWId()
get clockwise edge of range

Specified by:
getCWId in interface IdRange
Returns:
the id at the clockwise edge of the range (exclusive)

getComplementRange

public rice.p2p.commonapi.IdRange getComplementRange()
get the complement of this range

Specified by:
getComplementRange in interface IdRange
Returns:
This range's complement

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection