DOM Implementation
int[]
A node is represented with a node number, an index to access name code, parent node number, type code, first child index, number of children, child node numbers, first attribute index, number of attributes and attribute node numbers.
array fragmentation
Inserts and deletes into the child and attribute node arrays can be expensive with the need to copy the array into a smaller, bigger area, allocations. Also a management for the freed areas to be reused is needed.
Linked int[]
A node is represented as an integer number, an index to access the name code, parent node number, type code, first child node number, next and previous sibling node number and the first attribute node number.
7 integers = 28Bytes
Could be further optimized by encoding the type into the name code or the node number itself. Eg. still 1billion nodes with a 30 bit number.
Simple Node Object
A node is modeled as a simple class with name code attribute, parent node reference, child node array and attribute set.
1obj+2arr+4ref+1int = 52Bytes
The object (2 refs), 2 arrays (2x3 refs), parent, children, attribute refs, 1 ref in the parent's child or attribute array and 1 integer name code.
array fragmentation
Manage by the JVM memory manager.
Linked Node Object
A node is represented as an object with name code, parent, first child, next sibling, previous sibling and first attribute node reference.
/livcos.org/data/map/brainstorm/DomImplementation