|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.amino.ds.graph.AbstractGraph<E>
E - Type of elements in the graphpublic abstract class AbstractGraph<E>
Default implementation of Graph interface.
This graph doesn't allow duplicated key for all nodes. The constrain comes
from internal structure contains a ConcurrentHashMap which uses
indexed by key.
| Constructor Summary | |
|---|---|
AbstractGraph()
Default constructor. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E o)
|
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
|
boolean |
addAllNodes(java.util.Collection<Node<E>> nodes)
add all the nodes to graph. |
|
Node<E> |
addNode(E e)
Add a node to graph, which contains value e. |
|
Node<E> |
addNode(Node<E> node)
Add a node to graph, which contains value e. |
|
void |
clear()
|
|
abstract Graph<E> |
clone()
Clone this graph. |
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
boolean |
containsEdge(E start,
E end)
Returns whether this graph contains an edge between start and end. |
|
boolean |
containsNode(Node<E> node)
Judge if node is contained in graph. |
|
void |
dumpGraph()
for testing. |
|
protected boolean |
freeMultiOwnerShip(AdjacentList<E>[] targets)
release all ownership of every element in targets. |
|
java.util.Collection<Node<E>> |
getAllNodes()
get all the nodes in the graph. |
|
java.util.Collection<Edge<E>> |
getEdges(E start,
E end)
get all the edge start from the nodes which contain value start and end. |
|
java.util.Collection<Edge<E>> |
getEdges(Node<E> start,
Node<E> end)
get all all the edges which start from node start and end with node end. |
|
java.util.Collection<Edge<E>> |
getLinkedEdges(Node<E> node)
get all edges directly linked to the specified node. |
|
java.util.Collection<AdjacentNode<E>> |
getLinkedNodes(Node<E> node)
get all nodes which directly linked to node. |
|
protected boolean |
getMultiOwnerShip(AdjacentList<E>[] targets)
Get all ownership of multiple AdjacentList. |
|
java.util.Collection<Node<E>> |
getNodes(E e)
get all nodes whose value equal to e. |
|
boolean |
isEmpty()
|
|
java.util.Iterator<E> |
iterator()
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
boolean |
removeNode(Node<E> node)
remove the node from the graph. |
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
protected boolean |
simpleContentionManager(AdjacentList<E> targets)
manage contention of multithreads in the rush for ownership. |
|
protected boolean |
simpleContentionManager(AdjacentList<E>[] targets)
manage contention of multi-threads in the rush for ownership. |
|
int |
size()
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(E[] a)
|
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.amino.ds.graph.Graph |
|---|
addEdge, addEdge, addEdge, removeEdge, removeEdge, removeEdge |
| Methods inherited from interface java.util.Collection |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public AbstractGraph()
| Method Detail |
|---|
protected boolean getMultiOwnerShip(AdjacentList<E>[] targets)
targets - Collection of elements need ownership
protected boolean freeMultiOwnerShip(AdjacentList<E>[] targets)
targets - Collection of elements whose ownership is released
protected boolean simpleContentionManager(AdjacentList<E>[] targets)
targets - Array of elements whose ownership need to be got
protected boolean simpleContentionManager(AdjacentList<E> targets)
targets - element whose ownership need to be got
public Node<E> addNode(E e)
e, return the existing node instead of creating a new one. boolean addIfAbsent(E e) method?
addNode in interface Graph<E>e - the value to add.
public Node<E> addNode(Node<E> node)
e, return the existing node instead of creating a new one.
addNode in interface Graph<E>node - the node to add
node if succeed. If there is already a
graph node has the same value as node, return node
in graph.public boolean addAllNodes(java.util.Collection<Node<E>> nodes)
addAllNodes in interface Graph<E>nodes - nodes to be added
public boolean containsEdge(E start,
E end)
containsEdge in interface Graph<E>start - starting node of edgeend - ending node of edge
public java.util.Collection<AdjacentNode<E>> getLinkedNodes(Node<E> node)
node.
getLinkedNodes in interface Graph<E>node - start node
public java.util.Collection<Edge<E>> getLinkedEdges(Node<E> node)
node.
getLinkedEdges in interface Graph<E>node - start node
public boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>public void clear()
clear in interface java.util.Collection<E>public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<E>public boolean containsNode(Node<E> node)
containsNode in interface Graph<E>node - target node
public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>public java.util.Iterator<E> iterator()
iterator in interface java.lang.Iterable<E>iterator in interface java.util.Collection<E>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<E>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<E>public int size()
size in interface java.util.Collection<E>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<E>public boolean add(E o)
add in interface java.util.Collection<E>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<E>public boolean removeNode(Node<E> node)
removeNode in interface Graph<E>node - node removed
public java.util.Collection<Node<E>> getAllNodes()
getAllNodes in interface Graph<E>
public java.util.Collection<Edge<E>> getEdges(E start,
E end)
getEdges in interface Graph<E>start - start valueend - end value
public java.util.Collection<Edge<E>> getEdges(Node<E> start,
Node<E> end)
getEdges in interface Graph<E>start - the start node of the edgeend - the end node of the edge
public java.util.Collection<Node<E>> getNodes(E e)
e.
getNodes in interface Graph<E>e - value to be got
public void dumpGraph()
public abstract Graph<E> clone()
throws java.lang.CloneNotSupportedException
clone in interface Graph<E>clone in class java.lang.Objectjava.lang.CloneNotSupportedException - clone not supported
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||