3 ms·
You usually keep next/previous sibling to speed up iteration See: http://aosabook.org/en/posa/parsing-xml-at-the-speed-of-light.html#data-structures-for-the-do
by Ygg2 4y ago
You usually keep next/previous sibling to speed up iteration
See: http://aosabook.org/en/posa/parsing-xml-at-the-speed-of-light.html#data-structures-for-the-document-object-model http://aosabook.org/en/posa/parsing-xml-at-the-speed-of-ligh...
- c-smile 4y agoYou can store index of the node in parent m_children collection. Iteration on array is faster (cache locality) than DL list traversal. And there are issues when you traverse tree while changing it. In any case I've found that storing child nodes as m_children collection is more convenient in many cases. At least in Sciter (https://sciter.com https://sciter.com). struct node { weak_ref<element> m_parent; uint m_node_index; } struct element : node { vector<ref<node>> m_children; // strict ownership, sic! }