Rice Pastry API

rice.pastry
Class NodeSet

java.lang.Object
  extended byrice.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 3274 2006-05-15 16:17:47Z jeffh $
Author:
Peter Druschel
See Also:
Serialized Form

Field Summary
static short TYPE
          DESCRIBE THE FIELD
 
Constructor Summary
NodeSet()
          Constructor.
NodeSet(InputBuffer buf, NodeHandleFactory nhf)
          Constructor for NodeSet.
NodeSet(NodeSet o)
          Copy constructor.
NodeSet(java.util.Vector s)
          Constructor.
 
Method Summary
 NodeHandle get(Id nid)
          Finds the NodeHandle associated with a NodeId.
 NodeHandle get(int i)
          Gets the ith element in the set.
 NodeHandle getHandle(Id id)
          Finds the NodeHandle associated with the NodeId.
 NodeHandle getHandle(int i)
          Gets the ith element in the set.
 int getIndex(Id nid)
          Gets the index of the element with the given node id.
 int getIndex(NodeHandle nh)
          Gets the Index attribute of the NodeSet object
 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
 short getType()
          Gets the Type attribute of the NodeSet object
 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
 NodeHandle remove(Id nid)
          Removes a node id and its handle from the set.
 void remove(int index)
          remove a member at a given position
 NodeHandle remove(NodeHandle handle)
          remove a member
 NodeHandle removeHandle(Id id)
          Removes a node id and its handle from the set.
 void serialize(OutputBuffer buf)
          DESCRIBE THE METHOD
 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
 

Field Detail

TYPE

public static final short TYPE
DESCRIBE THE FIELD

See Also:
Constant Field Values
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

NodeSet

public NodeSet(InputBuffer buf,
               NodeHandleFactory nhf)
        throws java.io.IOException
Constructor for NodeSet.

Parameters:
buf - DESCRIBE THE PARAMETER
nhf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION
Method Detail

get

public NodeHandle get(Id 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(Id 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

getType

public short getType()
Gets the Type attribute of the NodeSet object

Specified by:
getType in interface NodeHandleSet
Returns:
The Type value

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(Id 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

serialize

public void serialize(OutputBuffer buf)
               throws java.io.IOException
DESCRIBE THE METHOD

Specified by:
serialize in interface NodeHandleSet
Parameters:
buf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection