NodeIndexer¶
This class describes a node indexer (a list of nodes).
You can get node indexers directly from the SAMSON facade (samson.Facade.SAMSON
) or for each node through a getNodes
function. To select specific nodes you can use the pagenodespecificationlanguage.
Getting nodes using the SAMSON facade (samson.Facade.SAMSON
):
# get all nodes in the active document
nodeIndexer = SAMSON.getNodes()
# get all atoms in the active document
nodeIndexer = SAMSON.getNodes('node.type atom')
# the same using short names
nodeIndexer = SAMSON.getNodes('n.t a')
# you can check the size of the indexer
nodeIndexer.size
Getting node’s children nodes:
# get all node's children atoms
nodeIndexer = node.getNodes('node.type atom')
See also
See the pagenodespecificationlanguage for more information and usage examples.
You can loop over the node indexer in a pythonic way:
for node in nodeIndexer:
print(node)
See also
SAMSON API: sbddatagraphnodeindexer
-
class
samson.DataModel.DataGraph.
NodeIndexer
(*args, **kwargs)¶ Bases:
pybind11_builtins.pybind11_object
This class describes a node indexer.
Overloaded function.
- __init__(self: samson.DataModel.DataGraph.NodeIndexer) -> None
Constructs a node indexer
- __init__(self: samson.DataModel.DataGraph.NodeIndexer, initialSize: int) -> None
Constructs a node indexer with a pre-allocated initialSize
-
addNode
(self: samson.DataModel.DataGraph.NodeIndexer, node: samson.DataModel.DataGraph.Node) → int¶ Adds a node to the indexer and returns the index of the node
-
clear
(self: samson.DataModel.DataGraph.NodeIndexer) → None¶ clear the node indexer
-
getIndex
(self: samson.DataModel.DataGraph.NodeIndexer, node: samson.DataModel.DataGraph.Node) → int¶ Returns the index associated to the node
-
getNode
(self: samson.DataModel.DataGraph.NodeIndexer, index: int) → samson.DataModel.DataGraph.Node¶ Returns the node with the given inde
-
getNodes
(self: samson.DataModel.DataGraph.Node, selectionString: str = '*', visitString: str = '*', includeDependencies: bool = False) → samson.DataModel.DataGraph.NodeIndexer¶ - Returns nodes (in a node indexer), based on a selectionString and a visitString, with our without dependencies).
- For selectionString and visitString use Node Specification Language (SAMSON API: pagenodespecificationlanguage
-
getRootNodes
(self: samson.DataModel.DataGraph.NodeIndexer) → samson.DataModel.DataGraph.NodeIndexer¶ Returns a node indexer with the root nodes among the indexed nodes, i.e. the nodes that do not have indexed ascendants
-
hasIndex
(self: samson.DataModel.DataGraph.NodeIndexer, arg0: samson.DataModel.DataGraph.Node) → bool¶ Returns true if the node has an index
-
hasNode
(self: samson.DataModel.DataGraph.NodeIndexer, node: samson.DataModel.DataGraph.Node) → bool¶ Returns true if the node has an index
-
printDebugInfo
(self: samson.DataModel.DataGraph.NodeIndexer) → None¶ Prints some debugging information in stdout
-
removeNode
(self: samson.DataModel.DataGraph.NodeIndexer, node: samson.DataModel.DataGraph.Node) → int¶ Erases the node from the indexer
-
isEmpty
¶ true if empty
-
size
¶ size of the node indexer