protected static class DirectedAcyclicGraph.VisitedArrayImpl extends Object implements DirectedAcyclicGraph.VisitedStrategy, DirectedAcyclicGraph.VisitedStrategyFactory
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.
Constructor and Description |
---|
VisitedArrayImpl()
Constructs empty instance
|
VisitedArrayImpl(DirectedAcyclicGraph.Region region)
Construct an empty instance for a region.
|
Modifier and Type | Method and 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 of
DirectedAcyclicGraph.VisitedStrategy . |
void |
setVisited(int index)
Mark the given topological index as visited.
|
public VisitedArrayImpl()
public VisitedArrayImpl(DirectedAcyclicGraph.Region region)
region
- the regionpublic DirectedAcyclicGraph.VisitedStrategy getVisitedStrategy(DirectedAcyclicGraph.Region affectedRegion)
DirectedAcyclicGraph.VisitedStrategyFactory
DirectedAcyclicGraph.VisitedStrategy
.getVisitedStrategy
in interface DirectedAcyclicGraph.VisitedStrategyFactory
affectedRegion
- the affected regionDirectedAcyclicGraph.VisitedStrategy
for the affected regionpublic void setVisited(int index)
DirectedAcyclicGraph.VisitedStrategy
setVisited
in interface DirectedAcyclicGraph.VisitedStrategy
index
- the topological indexpublic boolean getVisited(int index)
DirectedAcyclicGraph.VisitedStrategy
getVisited
in interface DirectedAcyclicGraph.VisitedStrategy
index
- the topological indexpublic void clearVisited(int index) throws UnsupportedOperationException
DirectedAcyclicGraph.VisitedStrategy
clearVisited
in interface DirectedAcyclicGraph.VisitedStrategy
index
- the indexUnsupportedOperationException
- 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.Copyright © 2018. All rights reserved.