- java.lang.Object
-
- org.jgrapht.graph.DirectedAcyclicGraph.VisitedBitSetImpl
-
- All Implemented Interfaces:
java.io.Serializable,DirectedAcyclicGraph.VisitedStrategy,DirectedAcyclicGraph.VisitedStrategyFactory
- Enclosing class:
- DirectedAcyclicGraph<V,E>
protected static class DirectedAcyclicGraph.VisitedBitSetImpl extends java.lang.Object implements DirectedAcyclicGraph.VisitedStrategy, DirectedAcyclicGraph.VisitedStrategyFactory
A visited strategy which uses aBitSet.This implementation is close to the performance of
DirectedAcyclicGraph.VisitedArrayListImpl, with 1/8 the memory usage.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DirectedAcyclicGraph.RegionaffectedRegionprivate static longserialVersionUIDprivate java.util.BitSetvisited
-
Constructor Summary
Constructors Constructor Description VisitedBitSetImpl()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearVisited(int index)Clear the visited state of the given topological index.booleangetVisited(int index)Get if the given topological index has been visited.DirectedAcyclicGraph.VisitedStrategygetVisitedStrategy(DirectedAcyclicGraph.Region affectedRegion)Create a new instance ofDirectedAcyclicGraph.VisitedStrategy.voidsetVisited(int index)Mark the given topological index as visited.private inttranslateIndex(int index)We translate the topological index to an ArrayList index.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
visited
private final java.util.BitSet visited
-
affectedRegion
private DirectedAcyclicGraph.Region affectedRegion
-
-
Method Detail
-
getVisitedStrategy
public DirectedAcyclicGraph.VisitedStrategy getVisitedStrategy(DirectedAcyclicGraph.Region affectedRegion)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategyFactoryCreate a new instance ofDirectedAcyclicGraph.VisitedStrategy.- Specified by:
getVisitedStrategyin interfaceDirectedAcyclicGraph.VisitedStrategyFactory- Parameters:
affectedRegion- the affected region- Returns:
- a new instance of
DirectedAcyclicGraph.VisitedStrategyfor the affected region
-
setVisited
public void setVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategyMark the given topological index as visited.- Specified by:
setVisitedin interfaceDirectedAcyclicGraph.VisitedStrategy- Parameters:
index- the topological index
-
getVisited
public boolean getVisited(int index)
Description copied from interface:DirectedAcyclicGraph.VisitedStrategyGet if the given topological index has been visited.- Specified by:
getVisitedin 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 java.lang.UnsupportedOperationExceptionDescription copied from interface:DirectedAcyclicGraph.VisitedStrategyClear the visited state of the given topological index.- Specified by:
clearVisitedin interfaceDirectedAcyclicGraph.VisitedStrategy- Parameters:
index- the index- Throws:
java.lang.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.
-
translateIndex
private int translateIndex(int index)
We translate the topological index to an ArrayList index. We have to do this because topological indices can be negative, and we want to do it because we can make better use of space by only needing an ArrayList of size |AR|.- Returns:
- the ArrayList index
-
-