ePOST API

rice.pastry
Class IdSet

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

public class IdSet
extends java.lang.Object
implements IdSet

Represents a set of Pastry ids. *

Version:
$Id: IdSet.java 2575 2005-06-14 19:48:34Z jeffh $
Author:
Peter Druschel
See Also:
Serialized Form

Constructor Summary
IdSet()
          Constructor.
IdSet(java.util.SortedMap s)
          Constructor.
 
Method Summary
 void addId(Id id)
          add a member
 void addMember(Id id)
          add a member
 Id[] asArray()
          return this set as an array
 IdSet build()
          Returns a new, empty IdSet of this type
 java.lang.Object clone()
          Override clone() to make it publicly accessible
 byte[] getHash()
          compute a fingerprint of the members in this IdSet
 java.util.Iterator getIterator()
          return an iterator over the elements of this set
 byte[] hash()
          return a hash of this set
 boolean isMember(Id id)
          test membership
 boolean isMemberId(Id id)
          test membership
 Id maxMember()
          return the largest member id
 Id minMember()
          return the smallest member id
 int numElements()
          return the number of elements
 void removeId(Id id)
          remove a member
 void removeMember(Id id)
          remove a member
 IdSet subSet(Id from, Id to)
          return a subset of this set, consisting of the member ids in a given range
 IdSet subSet(IdRange range)
          return a subset of this set, consisting of the member ids in a given range
 IdSet subSet(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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdSet

public IdSet()
Constructor.


IdSet

public IdSet(java.util.SortedMap s)
Constructor. constructs

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

numElements

public int numElements()
return the number of elements

Specified by:
numElements in interface IdSet

addMember

public void addMember(Id id)
add a member

Parameters:
id - the id to add

removeMember

public void removeMember(Id id)
remove a member

Parameters:
id - the id to remove

isMember

public boolean isMember(Id id)
test membership

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

minMember

public Id minMember()
return the smallest member id

Returns:
the smallest id in the set

maxMember

public Id maxMember()
return the largest member id

Returns:
the largest id in the set

subSet

public IdSet subSet(Id from,
                    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 IdSet subSet(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 byte[] 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(Id id)
add a member

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

removeId

public void removeId(Id id)
remove a member

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

isMemberId

public boolean isMemberId(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

build

public IdSet build()
Returns a new, empty IdSet of this type

Specified by:
build in interface IdSet
Returns:
A new IdSet

subSet

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

Specified by:
subSet in interface IdSet
Parameters:
from - the lower end of the range (inclusive)
to - the upper end of the range (exclusive)
Returns:
the subset

hash

public byte[] hash()
return a hash of this set

Specified by:
hash in interface IdSet
Returns:
the hash of this set

asArray

public Id[] asArray()
return this set as an array

Specified by:
asArray in interface IdSet
Returns:
the array

clone

public java.lang.Object clone()
Description copied from interface: IdSet
Override clone() to make it publicly accessible

Specified by:
clone in interface IdSet
Overrides:
clone in class java.lang.Object
Returns:
A clone of this set

ePOST API

Copyright © 2001-2005 - Rice Pastry.