|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable rice.pastry.leafset.SimilarSet
public class SimilarSet
A set of nodes, ordered by numerical distance of their Id from the local Id
Constructor Summary | |
---|---|
SimilarSet(LeafSet leafSet,
NodeHandle localNode,
int size,
boolean cw)
Constructor. |
|
SimilarSet(LeafSet leafSet,
NodeHandle localNode,
int size,
boolean cw,
NodeHandle[] handles)
|
Method Summary | |
---|---|
void |
addNodeSetListener(NodeSetListener listener)
|
void |
addObserver(java.util.Observer o)
Deprecated. use addNodeSetListener |
void |
deleteObserver(java.util.Observer o)
Deprecated. use removeNodeSetListener |
void |
destroy()
|
NodeHandle |
get(Id nid)
Finds the NodeHandle associated with the Id. |
NodeHandle |
get(int i)
Gets the ith element in the set. |
NodeHandle |
get(NodeHandle nh)
|
java.util.Collection |
getCollection()
This is thread safe, in that it won't throw an error if not properly synchronized. |
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)
|
int |
getIndexHandle(Id id)
Gets the index of the element with the given node id. |
boolean |
member(Id nid)
|
boolean |
member(NodeHandle nid)
Verifies if the set contains this particular id. |
boolean |
memberHandle(Id id)
Verifies if the set contains this particular id. |
int |
mostSimilar(Id nid)
Impl that doesn't produce garbage Numerically closest node to a given a node. |
protected void |
notifyListeners(NodeHandle handle,
boolean added)
|
boolean |
put(NodeHandle handle)
Puts a NodeHandle into the set. |
boolean |
put(NodeHandle handle,
boolean suppressNotify)
|
boolean |
putHandle(NodeHandle handle)
Puts a NodeHandle into the set. |
NodeHandle |
remove(Id nid)
Removes a node id and its handle from the set. |
protected NodeHandle |
remove(int i)
Removes a node id and its handle from the set. |
NodeHandle |
remove(NodeHandle nh)
|
NodeHandle |
removeHandle(Id id)
Removes a node id and its handle from the set. |
void |
removeNodeSetListener(NodeSetListener listener)
|
int |
size()
Gets the current size of this set. |
protected void |
swap(int i,
int j)
swap two elements |
boolean |
test(NodeHandle handle)
Test if a NodeHandle belongs into the set. |
java.lang.String |
toString()
|
Methods inherited from class java.util.Observable |
---|
clearChanged, countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimilarSet(LeafSet leafSet, NodeHandle localNode, int size, boolean cw)
localNode
- the local nodesize
- the size of the similar set.cw
- true if this is the clockwise leafset halfpublic SimilarSet(LeafSet leafSet, NodeHandle localNode, int size, boolean cw, NodeHandle[] handles)
Method Detail |
---|
protected void swap(int i, int j)
i
- the index of the first elementj
- the indes of the second elementpublic boolean test(NodeHandle handle)
handle
- the handle to test.
public boolean put(NodeHandle handle)
handle
- the handle to put.
public boolean put(NodeHandle handle, boolean suppressNotify)
public void addObserver(java.util.Observer o)
addObserver
in class java.util.Observable
public void deleteObserver(java.util.Observer o)
deleteObserver
in class java.util.Observable
public void addNodeSetListener(NodeSetListener listener)
addNodeSetListener
in interface NodeSetEventSource
public void removeNodeSetListener(NodeSetListener listener)
removeNodeSetListener
in interface NodeSetEventSource
protected void notifyListeners(NodeHandle handle, boolean added)
public NodeHandle get(Id nid)
nid
- a node id.
public NodeHandle get(NodeHandle nh)
public NodeHandle get(int i)
i
- an index. i == -1 refers to the local node
public boolean member(NodeHandle nid)
nid
- a node id.
public boolean member(Id nid)
public NodeHandle remove(Id nid)
nid
- the node to remove.
public NodeHandle remove(NodeHandle nh)
protected NodeHandle remove(int i)
i
- the index of the node to remove.
public int getIndex(Id nid)
nid
- the node id.
public int getIndex(NodeHandle nh)
public int size()
public int mostSimilar(Id nid)
nid
- a node id.
public boolean putHandle(NodeHandle handle)
handle
- the handle to put.
public NodeHandle getHandle(int i)
i
- an index.
public boolean memberHandle(Id id)
id
- a node id.
public NodeHandle removeHandle(Id id)
nid
- the node to remove.
public int getIndexHandle(Id id) throws java.util.NoSuchElementException
id
- the id.
java.util.NoSuchElementException
public java.util.Collection getCollection()
public java.lang.String toString()
toString
in class java.lang.Object
public void destroy()
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |