Package org.jgrapht.graph
Class DirectedAcyclicGraph.VisitedArrayImpl
- java.lang.Object
-
- org.jgrapht.graph.DirectedAcyclicGraph.VisitedArrayImpl
-
- All Implemented Interfaces:
Serializable
,DirectedAcyclicGraph.VisitedStrategy
,DirectedAcyclicGraph.VisitedStrategyFactory
- Enclosing class:
- DirectedAcyclicGraph<V,E>
protected static class DirectedAcyclicGraph.VisitedArrayImpl extends Object implements DirectedAcyclicGraph.VisitedStrategy, DirectedAcyclicGraph.VisitedStrategyFactory
A visited strategy using an array.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.
- Author:
- Peter Giles
- See Also:
- Serialized Form
-
-
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 void
clearVisited(int index)
Clear the visited state of the given topological index.boolean
getVisited(int index)
Get if the given topological index has been visited.DirectedAcyclicGraph.VisitedStrategy
getVisitedStrategy(DirectedAcyclicGraph.Region affectedRegion)
Create a new instance ofDirectedAcyclicGraph.VisitedStrategy
.void
setVisited(int index)
Mark the given topological index as visited.
-
-
-
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
-
getVisitedStrategy
public DirectedAcyclicGraph.VisitedStrategy getVisitedStrategy(DirectedAcyclicGraph.Region affectedRegion)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategyFactory
Create a new instance ofDirectedAcyclicGraph.VisitedStrategy
.- Specified by:
getVisitedStrategy
in interfaceDirectedAcyclicGraph.VisitedStrategyFactory
- Parameters:
affectedRegion
- the affected region- Returns:
- a new instance of
DirectedAcyclicGraph.VisitedStrategy
for the affected region
-
setVisited
public void setVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategy
Mark the given topological index as visited.- Specified by:
setVisited
in interfaceDirectedAcyclicGraph.VisitedStrategy
- Parameters:
index
- the topological index
-
getVisited
public boolean getVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategy
Get if the given topological index has been visited.- Specified by:
getVisited
in interfaceDirectedAcyclicGraph.VisitedStrategy
- Parameters:
index
- the topological index- Returns:
- true if the given topological index has been visited, false otherwise
-
clearVisited
public void clearVisited(int index) throws UnsupportedOperationException
Description copied from interface:DirectedAcyclicGraph.VisitedStrategy
Clear the visited state of the given topological index.- Specified by:
clearVisited
in interfaceDirectedAcyclicGraph.VisitedStrategy
- Parameters:
index
- the index- Throws:
UnsupportedOperationException
- if the implementation doesn't support (or doesn't need) clearance. For example, if the factory creates a new instance every time, it is a waste of cycles to reset the state after the search of the Affected Region is done, so an UnsupportedOperationException *should* be thrown.
-
-