Rice Pastry API

rice.pastry
Class IdSet

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

public class IdSet
extends java.lang.Object
implements IdSet

Represents a set of Pastry ids. *

Version:
$Id: IdSet.java,v 1.14 2003/07/22 07:14:20 amislove Exp $
Author:
Peter Druschel
See Also:
Serialized Form

Constructor Summary
  IdSet()
          Constructor.
  IdSet(rice.pastry.IdSet o)
          Copy constructor.
protected IdSet(java.util.TreeSet s)
          Constructor.
 
Method Summary
 void addId(rice.p2p.commonapi.Id id)
          add a member
 void addMember(rice.pastry.Id id)
          add a member
 rice.pastry.Id getHash()
          compute a fingerprint of the members in this IdSet
 java.util.Iterator getIterator()
          return an iterator over the elements of this set
 boolean isMember(rice.pastry.Id id)
          test membership
 boolean isMemberId(rice.p2p.commonapi.Id id)
          test membership
 rice.pastry.Id maxMember()
          return the largest member id
 rice.pastry.Id minMember()
          return the smallest member id
 int numElements()
          return the number of elements
 void removeId(rice.p2p.commonapi.Id id)
          remove a member
 void removeMember(rice.pastry.Id id)
          remove a member
 rice.pastry.IdSet subSet(rice.pastry.Id from, rice.pastry.Id to)
          return a subset of this set, consisting of the member ids in a given range
 rice.pastry.IdSet subSet(rice.pastry.IdRange range)
          return a subset of this set, consisting of the member ids in a given range
 rice.p2p.commonapi.IdSet subSet(rice.p2p.commonapi.IdRange range)
          return a subset of this set, consisting of the member ids in a given range
 java.lang.String toString()
          Returns a string representation of the IdSet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdSet

public IdSet()
Constructor.


IdSet

protected IdSet(java.util.TreeSet s)
Constructor. constructs a shallow copy of the given TreeSet s.

Parameters:
s - the TreeSet based on which we construct a new IdSet

IdSet

public IdSet(rice.pastry.IdSet o)
Copy constructor. constructs a shallow copy of the given IdSet o.

Parameters:
o - the IdSet to copy
Method Detail

numElements

public int numElements()
return the number of elements

Specified by:
numElements in interface IdSet

addMember

public void addMember(rice.pastry.Id id)
add a member

Parameters:
id - the id to add

removeMember

public void removeMember(rice.pastry.Id id)
remove a member

Parameters:
id - the id to remove

isMember

public boolean isMember(rice.pastry.Id id)
test membership

Parameters:
id - the id to test
Returns:
true of id is a member, false otherwise

minMember

public rice.pastry.Id minMember()
return the smallest member id

Returns:
the smallest id in the set

maxMember

public rice.pastry.Id maxMember()
return the largest member id

Returns:
the largest id in the set

subSet

public rice.pastry.IdSet subSet(rice.pastry.Id from,
                                rice.pastry.Id to)
return a subset of this set, consisting of the member ids in a given range

Parameters:
from - the counterclockwise end of the range (inclusive)
to - the clockwise end of the range (exclusive)
Returns:
the subset

subSet

public rice.pastry.IdSet subSet(rice.pastry.IdRange range)
return a subset of this set, consisting of the member ids in a given range

Parameters:
range - the range
Returns:
the subset

getIterator

public java.util.Iterator getIterator()
return an iterator over the elements of this set

Specified by:
getIterator in interface IdSet
Returns:
the interator

getHash

public rice.pastry.Id getHash()
compute a fingerprint of the members in this IdSet

Returns:
an Id containing the secure hash of this set

toString

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

Overrides:
toString in class java.lang.Object

addId

public void addId(rice.p2p.commonapi.Id id)
add a member

Specified by:
addId in interface IdSet
Parameters:
id - the id to add

removeId

public void removeId(rice.p2p.commonapi.Id id)
remove a member

Specified by:
removeId in interface IdSet
Parameters:
id - the id to remove

isMemberId

public boolean isMemberId(rice.p2p.commonapi.Id id)
test membership

Specified by:
isMemberId in interface IdSet
Parameters:
id - the id to test
Returns:
true of id is a member, false otherwise

subSet

public rice.p2p.commonapi.IdSet subSet(rice.p2p.commonapi.IdRange range)
return a subset of this set, consisting of the member ids in a given range

Specified by:
subSet in interface IdSet
Returns:
the subset

Rice Pastry API

Copyright © 2001 - Rice Pastry.


Imprint-Dataprotection