Class TopologicalShapeSort


public final class TopologicalShapeSort extends Object
Topologically sorts shapes based on their dependencies (i.e., mixins).

While this class is reusable, it is also stateful; shapes and edges are enqueued, and when sorted, all shapes and edges are dequeued.

  • Constructor Details

    • TopologicalShapeSort

      public TopologicalShapeSort()
  • Method Details

    • enqueue

      public void enqueue(Shape shape)
      Add a shape to the sort queue, and automatically extract dependencies.
      shape - Shape to add.
    • enqueue

      public void enqueue(ShapeId shape, Collection<ShapeId> dependencies)
      Add a shape to the sort queue, and provide an explicit dependencies list.
      shape - Shape to add.
      dependencies - Dependencies of the shape.
    • dequeueSortedShapes

      public List<ShapeId> dequeueSortedShapes()
      Sort the shapes and returns the ordered list of shape IDs.
      Returns the topologically sorted list of shape IDs.
      TopologicalShapeSort.CycleException - if cycles exist between shapes.