Top Description Inners Fields Constructors Methods
org.glassfish.pfl.basic.graph

public Class GraphImpl<T extends Node<T>>

extends AbstractSet<T extends Node<T>>
implements Graph<T extends Node<T>>
Class Inheritance
All Implemented Interfaces
org.glassfish.pfl.basic.graph.Graph, java.util.Set, java.util.Collection, java.lang.Iterable
Type Parameters
<T>
The type of a Node in the graph, which must extend Node.
Imports
java.util.AbstractSet, .ArrayList, .Collection, .HashMap, .HashSet, .Iterator, .Map, .Set

Implementation of a simple graph.
Author
ken

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface

Field Summary

Modifier and TypeField and Description
private Map<T, NodeData>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(T obj)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Adds the specified element to this set if it is not already present (optional operation).

private void
private Set<T>
public NodeData
public Set<T>
public Iterator<T>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.

private void
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).

pack-priv void
Inherited from java.util.AbstractSet:
equalshashCoderemoveAll

Field Detail

nodeToDataback to summary
private Map<T, NodeData> nodeToData

Constructor Detail

GraphImplback to summary
public GraphImpl()
GraphImplback to summary
public GraphImpl(Collection<T> coll)

Method Detail

addback to summary
public boolean add(T obj)

Overrides java.util.AbstractCollection.add.

Implements java.util.Set.add, java.util.Collection.add.

Doc from java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e to this set if the set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throw an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the elements that they may contain.

Annotations
@Override
clearNodeDataback to summary
private void clearNodeData()
collectRootSetback to summary
private Set<T> collectRootSet()
getNodeDataback to summary
public NodeData getNodeData(T node)

Implements org.glassfish.pfl.basic.graph.Graph.getNodeData.

getRootsback to summary
public Set<T> getRoots()

Implements org.glassfish.pfl.basic.graph.Graph.getRoots.

iteratorback to summary
public Iterator<T> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

markNonRootsback to summary
private void markNonRoots()
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

visitAllback to summary
pack-priv void visitAll(GraphImpl.NodeVisitor<T> nv)
org.glassfish.pfl.basic.graph back to summary

pack-priv Interface GraphImpl.NodeVisitor<T extends Node>


Method Summary

Modifier and TypeMethod and Description
public void
visit(Graph<T> graph, T node, NodeData nd)

Method Detail

visitback to summary
public void visit(Graph<T> graph, T node, NodeData nd)