Class TopologicalIndex
 All Implemented Interfaces:
KnowledgeIndex
This kind of reverse topological ordering is useful for languages
like C++ that need to define shapes before they can be referenced.
Only nonrecursive shapes are reversetopologically ordered using
getOrderedShapes()
. However, recursive shapes are queryable
through getRecursiveShapes()
. When this returned Set
is
iterated, recursive shapes are ordered by their degree of recursion (the
number of edges across all recursive closures), and then by shape ID
when multiple shapes have the same degree of recursion.
The recursion closures of a shape can be queried using
getRecursiveClosure(ToShapeId)
. This method returns a list of
paths from the shape back to itself. This list can be useful for code
generation to generate different code based on if a recursive path
passes through particular types of shapes.

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionGets all reversetopologically ordered shapes, including members.getRecursiveClosure
(ToShapeId shape) Gets the recursive closure of a given shape represented asPathFinder.Path
objects.Gets all shapes that have edges that are part of a recursive closure, including container shapes (list/set/map/structure/union) and members.boolean
isRecursive
(ToShapeId shape) Checks if the given shape has edges with recursive references.static TopologicalIndex
Creates a newTopologicalIndex
.

Constructor Details

TopologicalIndex


Method Details

of
Creates a newTopologicalIndex
. Parameters:
model
 Model to create the index from. Returns:
 The created (or previously cached)
TopologicalIndex
.

getOrderedShapes
Gets all reversetopologically ordered shapes, including members.When the returned
Set
is iterated, shapes are returned in reversetopological. Note that the returned set does not contain recursive shapes. Returns:
 Nonrecursive shapes in a reversetopological ordered
Set
.

getRecursiveShapes
Gets all shapes that have edges that are part of a recursive closure, including container shapes (list/set/map/structure/union) and members.When iterated, the returned
Set
is ordered from fewest number of edges to the most number of edges in the recursive closures, and then alphabetically by shape ID when there are multiple entries with the same number of edges. Returns:
 All shapes that are part of a recursive closure.

isRecursive
Checks if the given shape has edges with recursive references. Parameters:
shape
 Shape to check. Returns:
 True if the shape has recursive edges.

getRecursiveClosure
Gets the recursive closure of a given shape represented asPathFinder.Path
objects.The first element of each path is the given
shape
, and the last element of each path is the first shape that is encountered a second time in the path (i.e., the point of recursion). Parameters:
shape
 Shape to get the recursive closures of. Returns:
 The closures of the shape, or an empty
Set
if the shape is not recursive.
