GraphAddNodeL
Description
Add a node using l-value semantics and return its node id.
Ownership of node payload is transferred to graph when node copy-init is not set. In that case the provided l-value is zeroed after insertion.
Parameters
| Name | Direction | Description |
|---|---|---|
g |
in,out | Graph to modify. |
lval |
in | Node payload l-value to insert. |
Success
Node id assigned to inserted node.
Failure
Does not return on invalid arguments.
Usage example (Cross-references)
Usage examples (Cross-references)
static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const char *name) {
Str intersection = StrInitFromZstr(name);
GraphNodeId id = GraphAddNodeL(graph, intersection);
MapInsertR(index, name, id);- In
Graph.Init.c:71:
Str *stored_name;
node_id = GraphAddNodeL(&graph, name);
node = GraphGetNode(&graph, node_id);
stored_name = GraphNodeDataPtr(&graph, node); int shared = 7;
GraphNodeId id0 = GraphAddNodeL(&graph, owned);
GraphNodeId id1 = GraphAddNodeR(&graph, shared);- In
Insert.h:54:
/// TAGS: Graph, Node, Insert, Ownership
///
#define GraphAddNode(g, lval) GraphAddNodeL((g), (lval))
///
Last updated on