Package org.jgrapht.experimental.dag
Class DirectedAcyclicGraph.VisitedArrayImpl
- java.lang.Object
-
- org.jgrapht.experimental.dag.DirectedAcyclicGraph.VisitedArrayImpl
-
- All Implemented Interfaces:
java.io.Serializable,DirectedAcyclicGraph.Visited,DirectedAcyclicGraph.VisitedFactory
- Enclosing class:
- DirectedAcyclicGraph<V,E>
public static class DirectedAcyclicGraph.VisitedArrayImpl extends java.lang.Object implements DirectedAcyclicGraph.Visited, DirectedAcyclicGraph.VisitedFactory
This implementation, somewhat to my surprise, is slower than the ArrayList version, probably due to its reallocation of the underlying array for every topology reorder that is required.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DirectedAcyclicGraph.Regionregionprivate static longserialVersionUIDprivate boolean[]visited
-
Constructor Summary
Constructors Constructor Description VisitedArrayImpl()Constructs empty instanceVisitedArrayImpl(DirectedAcyclicGraph.Region region)Construct an empty instance for a region.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearVisited(int index)Clear the visited state of the given topological indexDirectedAcyclicGraph.VisitedgetInstance(DirectedAcyclicGraph.Region affectedRegion)Create a new instance ofDirectedAcyclicGraph.Visited.booleangetVisited(int index)Has the given topological index been visited?voidsetVisited(int index)Mark the given topological index as visited
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
visited
private final boolean[] visited
-
region
private final DirectedAcyclicGraph.Region region
-
-
Constructor Detail
-
VisitedArrayImpl
public VisitedArrayImpl()
Constructs empty instance
-
VisitedArrayImpl
public VisitedArrayImpl(DirectedAcyclicGraph.Region region)
Construct an empty instance for a region.- Parameters:
region- the region
-
-
Method Detail
-
getInstance
public DirectedAcyclicGraph.Visited getInstance(DirectedAcyclicGraph.Region affectedRegion)
Description copied from interface:DirectedAcyclicGraph.VisitedFactoryCreate a new instance ofDirectedAcyclicGraph.Visited.- Specified by:
getInstancein interfaceDirectedAcyclicGraph.VisitedFactory- Parameters:
affectedRegion- the affected region- Returns:
- a new instance of
DirectedAcyclicGraph.Visitedfor the affected region
-
setVisited
public void setVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedMark the given topological index as visited- Specified by:
setVisitedin interfaceDirectedAcyclicGraph.Visited- Parameters:
index- the topological index
-
getVisited
public boolean getVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedHas the given topological index been visited?- Specified by:
getVisitedin interfaceDirectedAcyclicGraph.Visited- Parameters:
index- the topological index- Returns:
- true if the given topological index been visited, false otherwise
-
clearVisited
public void clearVisited(int index) throws java.lang.UnsupportedOperationExceptionDescription copied from interface:DirectedAcyclicGraph.VisitedClear the visited state of the given topological index- Specified by:
clearVisitedin interfaceDirectedAcyclicGraph.Visited- Parameters:
index- the index- Throws:
java.lang.UnsupportedOperationException- if the implementation doesn't support (or doesn't need) clearance. For example, if the factory vends a new instance every time, it is a waste of cycles to clear the state after the search of the Affected Region is done, so an UnsupportedOperationException *should* be thrown.
-
-