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 NodeSet

    java.lang.Object
      rice.pastry.NodeSet

All Implemented Interfaces:
  NodeHandleSet, NodeSetI, java.io.Serializable

public class NodeSet
extends java.lang.Object
implements NodeSetI, java.io.Serializable

Represents an ordered set of NodeHandles. *

Version:
  $Id: NodeSet.java 2665 2005-07-19 19:19:15Z jeffh $
Author:
  Peter Druschel
See Also:
  Serialized Form

Constructor Summary
`NodeSet()` Constructor.
`NodeSet(NodeSet o)` Copy constructor.
`NodeSet(java.util.Vector s)` Constructor.

Method Summary
`NodeHandle` | `get(int i)` Gets the ith element in the set.
`NodeHandle` | `get(NodeId nid)` Finds the NodeHandle associated with a NodeId.
`NodeHandle` | `getHandle(Id id)` Finds the NodeHandle associated with the NodeId.
`NodeHandle` | `getHandle(int i)` Gets the ith element in the set.
`int` | `getIndex(NodeHandle nh)` Gets the Index attribute of the NodeSet object
`int` | `getIndex(NodeId nid)` Gets the index of the element with the given node id.
`int` | `getIndexHandle(Id id)` Gets the index of the element with the given node id.
`java.util.Iterator` | `getIterator()` return an iterator that iterates over the elements of this set
`int` | `indexOf(NodeHandle handle)` determine rank of a member
`boolean` | `insert(int index, NodeHandle handle)` insert a member at the given index
`java.util.Iterator` | `iterator()` DESCRIBE THE METHOD
`boolean` | `member(NodeHandle handle)` test membership
`boolean` | `memberHandle(Id id)` Verifies if the set contains this particular id.
`boolean` | `put(NodeHandle handle)` Appends a member to the ordered set.
`boolean` | `putHandle(NodeHandle handle)` Puts a NodeHandle into the set.
`void` | `randomize(RandomSource random)` Method which randomizes the order of this NodeSet
`void` | `remove(int index)` remove a member at a given position
`NodeHandle` | `remove(NodeHandle handle)` remove a member
`NodeHandle` | `remove(NodeId nid)` Removes a node id and its handle from the set.
`NodeHandle` | `removeHandle(Id id)` Removes a node id and its handle from the set.
`int` | `size()` Gets the number of elements.
`java.lang.String` | `toString()` Returns a string representation of the NodeSet

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### NodeSet

    public NodeSet()

  Constructor.

### NodeSet

    public NodeSet(java.util.Vector s)

  Constructor.

Parameters:
  `s` - DESCRIBE THE PARAMETER

### NodeSet

    public NodeSet(NodeSet o)

  Copy constructor.

Parameters:
  `o` - DESCRIBE THE PARAMETER

Method Detail

### get

    public NodeHandle get(NodeId nid)

  Finds the NodeHandle associated with a NodeId.

  Specified by:
    `get` in interface `NodeSetI`
  Parameters:
    `nid` - a node id.
  Returns:
    the handle associated with that id or null if no such handle is found.

### get

    public NodeHandle get(int i)

  Gets the ith element in the set.

  Specified by:
    `get` in interface `NodeSetI`
  Parameters:
    `i` - an index.
  Returns:
    the handle, or null if the position is out of bounds

### getIndex

    public int getIndex(NodeId nid)

  Gets the index of the element with the given node id.

  Specified by:
    `getIndex` in interface `NodeSetI`
  Parameters:
    `nid` - the node id.
  Returns:
    the index or -1 if no such element

### getIndex

    public int getIndex(NodeHandle nh)

  Gets the Index attribute of the NodeSet object

  Specified by:
    `getIndex` in interface `NodeSetI`
  Parameters:
    `nh` - DESCRIBE THE PARAMETER
  Returns:
    The Index value

### getIterator

    public java.util.Iterator getIterator()

  return an iterator that iterates over the elements of this set

  Returns:
    the interator

### getHandle

    public NodeHandle getHandle(Id id)

  Finds the NodeHandle associated with the NodeId.

  Specified by:
    `getHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - a node id.
  Returns:
    the handle associated with that id or null if no such handle is found.

### getHandle

    public NodeHandle getHandle(int i)

  Gets the ith element in the set.

  Specified by:
    `getHandle` in interface `NodeHandleSet`
  Parameters:
    `i` - an index.
  Returns:
    the handle associated with that id or null if no such handle is found.

### getIndexHandle

    public int getIndexHandle(Id id)
                       throws java.util.NoSuchElementException

  Gets the index of the element with the given node id.

  Specified by:
    `getIndexHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - the id.
  Returns:
    the index or throws a NoSuchElementException.
  Throws:
    `java.util.NoSuchElementException` - DESCRIBE THE EXCEPTION

### put

    public boolean put(NodeHandle handle)

  Appends a member to the ordered set.

  Specified by:
    `put` in interface `NodeSetI`
  Parameters:
    `handle` - the handle to put.
  Returns:
    false if handle was already a member, true otherwise

### randomize

    public void randomize(RandomSource random)

  Method which randomizes the order of this NodeSet

  Parameters:
    `random` - DESCRIBE THE PARAMETER

### remove

    public NodeHandle remove(NodeId nid)

  Removes a node id and its handle from the set.

  Parameters:
    `nid` - the node to remove.
  Returns:
    the node handle removed or null if nothing.

### size

    public int size()

  Gets the number of elements.

  Specified by:
    `size` in interface `NodeSetI`
  Returns:
    the size.

### insert

    public boolean insert(int index,
                          NodeHandle handle)

  insert a member at the given index

  Parameters:
    `index` - the position at which to insert the element into the ordered set
    `handle` - the handle to add
  Returns:
    false if handle was already a member, true otherwise

### remove

    public NodeHandle remove(NodeHandle handle)

  remove a member

  Specified by:
    `remove` in interface `NodeSetI`
  Parameters:
    `handle` - the handle to remove
  Returns:
    DESCRIBE THE RETURN VALUE

### remove

    public void remove(int index)

  remove a member at a given position

  Parameters:
    `index` - the position of the member to remove

### indexOf

    public int indexOf(NodeHandle handle)

  determine rank of a member

  Parameters:
    `handle` - the handle to test
  Returns:
    rank (index) of the handle, or -1 if handle is not a member

### member

    public boolean member(NodeHandle handle)

  test membership

  Specified by:
    `member` in interface `NodeSetI`
  Parameters:
    `handle` - the handle to test
  Returns:
    true of handle is a member, false otherwise

### toString

    public java.lang.String toString()

  Returns a string representation of the NodeSet

  Returns:
    DESCRIBE THE RETURN VALUE

### putHandle

    public boolean putHandle(NodeHandle handle)

  Puts a NodeHandle into the set.

  Specified by:
    `putHandle` in interface `NodeHandleSet`
  Parameters:
    `handle` - the handle to put.
  Returns:
    true if the put succeeded, false otherwise.

### memberHandle

    public boolean memberHandle(Id id)

  Verifies if the set contains this particular id.

  Specified by:
    `memberHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - a node id.
  Returns:
    true if that node id is in the set, false otherwise.

### removeHandle

    public NodeHandle removeHandle(Id id)

  Removes a node id and its handle from the set.

  Specified by:
    `removeHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - DESCRIBE THE PARAMETER
  Returns:
    the node handle removed or null if nothing.

### iterator

    public java.util.Iterator iterator()

  DESCRIBE THE METHOD

  Returns:
    DESCRIBE THE RETURN VALUE

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.