Skip to content
Pieter van Ginkel edited this page Jun 13, 2015 · 1 revision

Arrays are implemented using a custom backing store. By default, the array store will simply store its items as a flat array. However, to prevent allocating too much memory, an alternative sparse storage is available.

The algorithm works as follows. When the array grows, a check is done for what the new size will become. If this is more than two times the size of the current capacity, and the current store is the flat store, the array will automatically switch to a sparse store.

The sparse array store has the following properties:

  • Chunks: The chunks of the sparse array,
  • Count: The number of chunks in use.

A chunk has the following properties:

  • Offset: The index of the first item of the chunk;
  • [Entry]: The entries of the chunk.

Clone this wiki locally