ePOST API

rice.pastry
Class IdRange

java.lang.Object
  extended by rice.pastry.IdRange
All Implemented Interfaces:
java.io.Serializable, IdRange

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

Represents a contiguous range of Pastry ids. *

Version:
$Id: IdRange.java 2735 2005-08-16 13:48:55Z jeffh $
Author:
Peter Druschel
See Also:
Serialized Form

Constructor Summary
IdRange()
          Constructor, constructs an empty IdRange
IdRange(boolean type)
           
IdRange(Id ccw, Id cw)
          Constructor.
IdRange(IdRange o)
          Copy constructor.
 
Method Summary
 IdRange ccwHalf()
          get counterclockwise half of the range
 IdRange complement()
          get the complement of this range on the ring
 boolean contains(Id key)
          test if a given key lies within this range
 boolean containsId(Id key)
          test if a given key lies within this range
 IdRange cwHalf()
          get clockwise half of the range
 IdRange diff(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)
 IdRange diffRange(IdRange range)
          diffs the given range with this range
 boolean equals(java.lang.Object obj)
          equality operator
 Id getCCW()
          get counterclockwise edge of range
 Id getCCWId()
          get counterclockwise edge of range
 IdRange getComplementRange()
          get the complement of this range
 Id getCW()
          get clockwise edge of range
 Id getCWId()
          get clockwise edge of range
 IdRange intersect(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)
 IdRange intersectRange(IdRange range)
          intersects the given range with this range
 boolean isAdjacent(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
 IdRange merge(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
 IdRange mergeRange(IdRange range)
          merges the given range with this range
 IdRange subtract(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(Id ccw,
               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(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

Specified by:
isEmpty in interface IdRange
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(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(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 Id getCCW()
get counterclockwise edge of range

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

getCW

public Id getCW()
get clockwise edge of range

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

merge

public IdRange merge(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 IdRange complement()
get the complement of this range on the ring

Returns:
the complement range

intersect

public IdRange intersect(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 IdRange diff(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 IdRange subtract(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 IdRange ccwHalf()
get counterclockwise half of the range

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

cwHalf

public 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(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 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 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 IdRange getComplementRange()
get the complement of this range

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

mergeRange

public IdRange mergeRange(IdRange range)
merges the given range with this range

Specified by:
mergeRange in interface IdRange
Returns:
The merge

diffRange

public IdRange diffRange(IdRange range)
diffs the given range with this range

Specified by:
diffRange in interface IdRange
Returns:
The merge

intersectRange

public IdRange intersectRange(IdRange range)
intersects the given range with this range

Specified by:
intersectRange in interface IdRange
Returns:
The merge

ePOST API

Copyright © 2001-2005 - Rice Pastry.