basically i have a doubly-linked list where each node needs to have an index associated with it.
typedef struct node{
struct node* prev;
struct node* next;
char* text;
uint32_t index;
} node_t;
if i want to insert or delete a node, i need to update the index of every node after it. Currently im doing something like this:
void increment_following_indices(node_t* node){
for(; node != NULL; node = node -> next)
++node -> index;
}
the problem is if i have tens of thousands of these nodes its gonna get slow. Should i use a different data structure or can someone help me find a clever solution?