T - the type of elements in this graphpublic class ConcurrentHashDirectedGraph<T> extends Object implements DirectedGraph<T>, Cloneable, Serializable
ConcurrentHashDirectedGraph class provides an implementation
of the DirectedGraph interface that uses a ConcurrentHashMap
to keep track of the graph.DirectedGraph.Node<T>| Constructor and Description |
|---|
ConcurrentHashDirectedGraph()
Instantiates a new
ConcurrentHashDirectedGraph object with
the default initial capacity (16) and the default load factor (0.75). |
ConcurrentHashDirectedGraph(int initialCapacity)
Instantiates a new
ConcurrentHashDirectedGraph object with the
specified initial capacity and the default load factor (0.75). |
ConcurrentHashDirectedGraph(int initialCapacity,
float loadFactor)
Instantiates a new
ConcurrentHashDirectedGraph object with the
specified initial capacity and load factor. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T e) |
void |
add(T start,
java.util.stream.Stream<T> dests)
Adds the specified nodes if they don't exist in the graph and build arcs
from the starting node to all the destination ones.
|
void |
add(T start,
T dest)
Adds the specified nodes if they don't exist in the graph and build an arc
from the starting node to the destination one.
|
boolean |
addAll(Collection<? extends T> c) |
void |
addEdge(T start,
T dest)
Adds an arc from the starting node to the destination one.
|
void |
clear() |
Object |
clone()
Returns a shallow copy of this ConcurrentHashDirectedGraph
instance: the values themselves are not cloned.
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
edgeExists(T start,
T dest)
Given two nodes in the graph, returns whether there is an edge from the
first node to the second node.
|
java.util.stream.Stream<T> |
edgesFrom(T node)
Given a node in the graph, returns a stream of the edges leaving that node.
|
boolean |
equals(Object obj) |
void |
forEach(java.util.function.Consumer<? super T> action) |
DirectedGraph.Node<T> |
get(T val)
Gets a node from this graph given its value.
|
Set<T> |
getEdgesFrom(T node)
Given a node in the graph, returns an immutable view of the edges
leaving that node as a set of endpoints.
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
Set<DirectedGraph.Node<T>> |
nodeSet()
Gets a
Set view of all the nodes contained in this directed graph. |
java.util.stream.Stream<T> |
parallelStream() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeEdge(T start,
T dest)
Removes the edge from the specified starting node to the specified destination
node from the graph.
|
boolean |
retainAll(Collection<?> c) |
int |
size() |
java.util.stream.Stream<T> |
stream() |
Object[] |
toArray() |
<A> A[] |
toArray(A[] a) |
String |
toString() |
finalize, getClass, notify, notifyAll, wait, wait, waitspliteratorremoveIfpublic ConcurrentHashDirectedGraph()
ConcurrentHashDirectedGraph object with
the default initial capacity (16) and the default load factor (0.75).public ConcurrentHashDirectedGraph(int initialCapacity)
ConcurrentHashDirectedGraph object with the
specified initial capacity and the default load factor (0.75).initialCapacity - the initial capacityIllegalArgumentException - if the initial capacity is negativepublic ConcurrentHashDirectedGraph(int initialCapacity,
float loadFactor)
ConcurrentHashDirectedGraph object with the
specified initial capacity and load factor.initialCapacity - the initial capacityloadFactor - he load factorIllegalArgumentException - if the initial capacity is negative
or the load factor is non-positivepublic int size()
size in interface Collection<T>size in interface Set<T>Set.size()public boolean isEmpty()
isEmpty in interface Collection<T>isEmpty in interface Set<T>Set.isEmpty()public boolean contains(Object o)
contains in interface Collection<T>contains in interface Set<T>Set.contains(java.lang.Object)public Iterator<T> iterator()
iterator in interface Iterable<T>iterator in interface Collection<T>iterator in interface Set<T>Set.iterator()public java.util.stream.Stream<T> stream()
stream in interface Collection<T>Collection.stream()public java.util.stream.Stream<T> parallelStream()
parallelStream in interface Collection<T>Collection.parallelStream()public void forEach(java.util.function.Consumer<? super T> action)
forEach in interface Iterable<T>Iterable.forEach(java.util.function.Consumer)public Object[] toArray()
toArray in interface Collection<T>toArray in interface Set<T>Set.toArray()public <A> A[] toArray(A[] a)
toArray in interface Collection<T>toArray in interface Set<T>Set.toArray(java.lang.Object[])public DirectedGraph.Node<T> get(T val)
get in interface DirectedGraph<T>val - the value for the node to retrievenull if the
graph doesn't contain a node with the specified valueDirectedGraph.get(java.lang.Object)public boolean add(T e)
add in interface Collection<T>add in interface Set<T>Set.add(java.lang.Object)public boolean remove(Object o)
remove in interface Collection<T>remove in interface Set<T>Set.remove(java.lang.Object)public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>containsAll in interface Set<T>Set.containsAll(java.util.Collection)public boolean addAll(Collection<? extends T> c)
addAll in interface Collection<T>addAll in interface Set<T>Set.addAll(java.util.Collection)public boolean retainAll(Collection<?> c)
retainAll in interface Collection<T>retainAll in interface Set<T>Set.retainAll(java.util.Collection)public boolean removeAll(Collection<?> c)
removeAll in interface Collection<T>removeAll in interface Set<T>Set.removeAll(java.util.Collection)public void clear()
clear in interface Collection<T>clear in interface Set<T>Set.clear()public Set<DirectedGraph.Node<T>> nodeSet()
Set view of all the nodes contained in this directed graph.
The set is backed by the graph, so changes to the graph are reflected in
the set, and vice-versa. If the graph is modified while an iteration over
the set is in progress (except through the iterator's own remove()
operation, or through the addEdge() or removeEdge()
operations on a graph node returned by the iterator) the results of the
iteration are undefined. The set supports node removal, which removes the
corresponding node from the graph, via the Iterator.remove(),
Set.remove, removeAll, retainAll,
and clear operations. It does not support the add
or addAll operations.
nodeSet in interface DirectedGraph<T>DirectedGraph.nodeSet()public void add(T start, T dest)
add in interface DirectedGraph<T>start - the starting nodedest - the destination nodeDirectedGraph.add(java.lang.Object, java.lang.Object)public void add(T start, java.util.stream.Stream<T> dests)
add in interface DirectedGraph<T>start - the starting nodedests - the destination nodesDirectedGraph.add(java.lang.Object, java.util.stream.Stream)public void addEdge(T start, T dest)
addEdge in interface DirectedGraph<T>start - the starting nodedest - the destination nodeDirectedGraph.addEdge(java.lang.Object, java.lang.Object)public boolean removeEdge(T start, T dest)
removeEdge in interface DirectedGraph<T>start - the starting nodedest - the destination nodetrue if an edge was removed; false
otherwiseDirectedGraph.removeEdge(java.lang.Object, java.lang.Object)public boolean edgeExists(T start, T dest)
edgeExists in interface DirectedGraph<T>start - the starting nodedest - the destination nodetrue if an edge exists from start to
dest; falseotherwiseDirectedGraph.edgeExists(java.lang.Object, java.lang.Object)public java.util.stream.Stream<T> edgesFrom(T node)
edgesFrom in interface DirectedGraph<T>node - the node whose edges should be queriedDirectedGraph.edgesFrom(java.lang.Object)public Set<T> getEdgesFrom(T node)
getEdgesFrom in interface DirectedGraph<T>node - the node whose edges should be queriedDirectedGraph.getEdgesFrom(java.lang.Object)public int hashCode()
hashCode in interface Collection<T>hashCode in interface Set<T>hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
equals in interface Collection<T>equals in interface Set<T>equals in class ObjectObject.equals(java.lang.Object)public Object clone()
public String toString()
toString in class ObjectObject.toString()Copyright (C) 2015-2015 The Helenus Driver Project Authors.