Optimize NodeLists and EdgeLists
NodeLists and EdgeLists need optimization. NodeList could be as follows - EdgeList the same:
- Linked list, as before
- One NodeList element now manages not just one node, but a range of node indices
- Each elem stores own index, next and two ints: min_index and max_index
-
8 + 4 + 4 + 4 = 20
bytes - NodeList element says “All indices between min_index and max_index are nodes”
- No more prev! Responsibility of yieldNextNode
-
- When iterating through nodes, resolve the value array in BigArray, remember it and iterate through it directly; avoid lots of indirect ptrs
- If a removed node is found, split the current NodeList into two - one for range of nodes before it and one for nodes after
- If the next NodeList is adjacent to current one, amalgamate both NodeLists into a bigger one (ie.
nlist2.min_index == nlist1.max_index+1
) - Check matched flag within iteration logic, not after retrieving pointer to node - avoid dereferencing pointer unnecessarily
Edited by Jack Romo