Module: gears.sort
Utilities to sort and arrange data.
gears.sort.topological Functions
:append (node, dependencies) |
Ensure that node appears after all dependencies .
|
|
:prepend (node, subordinates) |
Ensure that node appears before all subordinates .
|
|
:clone () -> gears.sort.topological | Create a copy of this topological sort. | |
:remove (node) | Remove a node from the topological map. | |
:sort () -> table or nil | Try to sort the nodes. | |
gears.sort.topological () | A topological sorting class. |
gears.sort.topological Functions
- 🔗 :append (node, dependencies)
-
Ensure that
node
appears after alldependencies
.Parameters:
Name Type(s) Description node The node that edges are added to. dependencies table List of nodes that have to appear before node
. - 🔗 :prepend (node, subordinates)
-
Ensure that
node
appears before allsubordinates
.Parameters:
Name Type(s) Description node The node that edges are added to. subordinates table List of nodes that have to appear after node
. - 🔗 :clone () -> gears.sort.topological
-
Create a copy of this topological sort.
This is useful to backup it before adding elements that can potentially
have circular dependencies and thus render the original useless.
Returns:
-
gears.sort.topological
The cloned sorter object.
- 🔗 :remove (node)
-
Remove a node from the topological map.
Parameters:
Name Type(s) Description node The node - 🔗 :sort () -> table or nil
-
Try to sort the nodes.
Returns:
-
table
A sorted list of nodes
Or
- nil
- A node around which a loop exists
- 🔗 gears.sort.topological ()
-
A topological sorting class.
The object returned by this function allows to create simple dependency graphs. It can be used for decision making or ordering of complex sequences.