3 ms·
Using indexes instead of pointers in data structures works well, and the cost of the base address + offset is negligible, as similar address calculation is alre
by faragon 2y ago
Using indexes instead of pointers in data structures works well, and the cost of the base address + offset is negligible, as similar address calculation is already generated by the compiler when accessing into an element of a data structure. In addition to that, mention that indexes can be used as offsets, or as an actual indexes of the size of an individual element, i.e. in that case non-trivial data structures with e.g. >= 32-byte elements could address hundreds of gigabytes of RAM.
A practical use could be e.g. using bit fields can be convenient, e.g. having 32-bit indexes, with the higher bit for the color in a Red-black tree. And in case of requiring dynamic-sized items in the tree nodes, these could be in different 32-bit addressable memory pools.