Skip to content
GraphNodeIdIndex

GraphNodeIdIndex

Description

Extract the slot index encoded in a node id.

Parameters

Name Direction Description
id in Graph node id.

Success

Low 32-bit slot index encoded in id.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
        const GenericGraphSlot *slot;
    
        index      = GraphNodeIdIndex(node_id);
        generation = GraphNodeIdGeneration(node_id);
    static GenericGraphSlot *graph_require_live_slot(GenericGraph *graph, GraphNodeId node_id) {
        graph_validate_node_id(graph, node_id);
        return graph_slot_ptr_raw(graph, GraphNodeIdIndex(node_id));
    }
    static const GenericGraphSlot *graph_require_live_slot_const(const GenericGraph *graph, GraphNodeId node_id) {
        graph_validate_node_id(graph, node_id);
        return graph_slot_ptr_const_raw(graph, GraphNodeIdIndex(node_id));
    }
            const GenericGraphSlot *slot;
    
            graph_validate_node_index_raw(graph, GraphNodeIdIndex(neighbor_id));
            slot = graph_slot_ptr_const_raw(graph, GraphNodeIdIndex(neighbor_id));
    
            graph_validate_node_index_raw(graph, GraphNodeIdIndex(neighbor_id));
            slot = graph_slot_ptr_const_raw(graph, GraphNodeIdIndex(neighbor_id));
    
            if (graph_slot_is_occupied(slot) && !graph_slot_is_marked(slot) && (slot->generation == GraphNodeIdGeneration(neighbor_id))) {
        ValidateGraph(graph);
    
        index      = GraphNodeIdIndex(node_id);
        generation = GraphNodeIdGeneration(node_id);
        GraphNodeId d = GraphAddNodeR(&graph, 40);
    
        result = result && (GraphNodeIdIndex(d) == GraphNodeIdIndex(b));
        result = result && (GraphNodeIdGeneration(d) == (GraphNodeIdGeneration(b) + 1));
        result = result && (GraphNodeData(&graph, GraphGetNode(&graph, d)) == 40);
        u64         counts[2] = {0};
    
        counts[GraphNodeIdIndex(a)] = 11;
        counts[GraphNodeIdIndex(b)] = 29;
    
        counts[GraphNodeIdIndex(a)] = 11;
        counts[GraphNodeIdIndex(b)] = 29;
    
        bool result = GraphMarkNodeForDeletion(GraphGetNode(&graph, b));
        GraphNodeId reused = GraphAddNodeR(&graph, 99);
    
        result = result && (GraphNodeIdIndex(reused) == GraphNodeIdIndex(b));
        result = result && (GraphNodeIdGeneration(reused) == (GraphNodeIdGeneration(b) + 1));
        result = result && (counts[GraphNodeIdIndex(reused)] == 29);
        result = result && (GraphNodeIdIndex(reused) == GraphNodeIdIndex(b));
        result = result && (GraphNodeIdGeneration(reused) == (GraphNodeIdGeneration(b) + 1));
        result = result && (counts[GraphNodeIdIndex(reused)] == 29);
    
        counts[GraphNodeIdIndex(reused)] = 0;
        result = result && (counts[GraphNodeIdIndex(reused)] == 29);
    
        counts[GraphNodeIdIndex(reused)] = 0;
        result = result && (counts[GraphNodeIdIndex(reused)] == 0);
        result = result && (counts[GraphNodeIdIndex(a)] == 11);
    
        counts[GraphNodeIdIndex(reused)] = 0;
        result = result && (counts[GraphNodeIdIndex(reused)] == 0);
        result = result && (counts[GraphNodeIdIndex(a)] == 11);
        result = result && (GraphNodeAt(&graph, reused) == 99);
        counts[GraphNodeIdIndex(reused)] = 0;
        result = result && (counts[GraphNodeIdIndex(reused)] == 0);
        result = result && (counts[GraphNodeIdIndex(a)] == 11);
        result = result && (GraphNodeAt(&graph, reused) == 99);
        }
    
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));
    
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(first_id))->generation == (first_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(second_id))->generation == (second_generation + 1));
        result = result && (VecPtrAt(&graph.slots, GraphNodeIdIndex(third_id))->generation == (third_generation + 1));
    
        GraphDeinit(&graph);
        stored_name = GraphNodeDataPtr(&graph, node);
    
        bool result = GraphNodeIdIndex(node_id) == 0 && name.data != NULL && GraphNodeCount(&graph) == 1 &&
                      ZstrCompare(stored_name->data, "alpha") == 0 && stored_name->data != name.data;
        GraphNode   node    = GraphGetNode(&graph, node_id);
    
        bool result = graph.alignment == 32 && GraphNodeIdIndex(node_id) == 0 && GraphNodeIdGeneration(node_id) == 1;
        result      = result && GraphNodeGetId(node) == node_id;
        result      = result && GraphNodeIndex(node) == 0;
        result      = result && GraphNodeData(&graph, node_b) == 25;
        result      = result && GraphNodeGetId(node_b) == b;
        result      = result && GraphNodeIndex(node_b) == GraphNodeIdIndex(b);
        result      = result && GraphOutDegree(&graph, a) == 2;
        result      = result && GraphInDegree(&graph, a) == 1;
        GraphNodeId id1 = GraphAddNodeR(&graph, shared);
    
        bool result = GraphNodeIdIndex(id0) == 0 && GraphNodeIdGeneration(id0) == 1 && GraphNodeIdIndex(id1) == 1;
        result      = result && owned == 0 && shared == 7;
        result      = result && GraphNodeAt(&graph, id0) == 42;
    /// TAGS: Graph, Node, Index, Handle
    ///
    #define GraphNodeIndex(node) GraphNodeIdIndex(GraphNodeGetId(node))
    
    ///
Last updated on