Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.pastry
Class IdSet

    java.lang.Object
      rice.pastry.IdSet

All Implemented Interfaces:
  java.io.Serializable, IdSet

    public final class IdSet

extends java.lang.Object
implements IdSet

Represents a set of Pastry ids. needs to be final otherwise: clone method does not call super.clone() This non-final class defines a clone() method that does not call super. clone(). If this class ("A") is extended by a subclass ("B"), and the subclass B calls super.clone(), then it is likely that B's clone() method will return an object of type A, which violates the standard contract for clone(). If all clone() methods call super.clone(), then they are guaranteed to use Object.clone(), which always returns an object of the correct type.

Version:
  $Id: IdSet.java 3613 2007-02-15 14:45:14Z jstewart $
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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.