I haven't looked at the code but that's my first impression given the nomenclature.
I haven't looked at the code but that's my first impression given the nomenclature.
You may have children accounted as DL list and so each Node should have m_next / m_previous node references. + Parent node to have m_first_child reference (if list is circular). + m_parent (Node) reference.
So you need 4 pointers per each non-terminal node. Or 3 pointers for terminals.
Otherwise (vector of children):
You need only m_parent (Node) reference in terminals. And in container nodes additional vector<NodePtr> m_children; to store child references.
You want sibling nodes otherwise you will have to traverse back to the root node sometimes to find a sibling.
You do need parent, check this: https://developer.mozilla.org/en-US/docs/Web/API/Node/parent...
> You want sibling nodes otherwise you will have to traverse back to the root node sometimes to find a sibling.
The only need for this is in Node.nextSibling implementation: https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSi...
Where vector<>::find is pretty sufficient.
But in reality (at least in my Sciter) node stores its index in parent's m_children so it is O(1) operation.
and ~ combinator and :nth-child(n) selector for that matter too.