public final class TopologicalShapeSort
extends java.lang.Object
While this class is reusable, it is also stateful; shapes and edges are enqueued, and when sorted, all shapes and edges are dequeued.
| Modifier and Type | Class and Description |
|---|---|
static class |
TopologicalShapeSort.CycleException
Thrown when cycles exist between shapes.
|
| Constructor and Description |
|---|
TopologicalShapeSort() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<ShapeId> |
dequeueSortedShapes()
Sort the shapes and returns the ordered list of shape IDs.
|
void |
enqueue(Shape shape)
Add a shape to the sort queue, and automatically extract dependencies.
|
void |
enqueue(ShapeId shape,
java.util.Collection<ShapeId> dependencies)
Add a shape to the sort queue, and provide an explicit dependencies list.
|
public void enqueue(Shape shape)
shape - Shape to add.public void enqueue(ShapeId shape, java.util.Collection<ShapeId> dependencies)
shape - Shape to add.dependencies - Dependencies of the shape.public java.util.List<ShapeId> dequeueSortedShapes()
TopologicalShapeSort.CycleException - if cycles exist between shapes.