contiguous
address computation is purely arithmetic
discontinuous
elements are stored in multiple, non-adjacent regions
address computation requires at least one indirection
typical realizations
enables growth and removal without relocating existing elements
trades locality and simplicity for stability and flexibility
pointer stable
index stable
once an index is assigned, it permanently identifies the same logical element
index becomes an identity rather than a position
requires indirection, tombstones, or fixed slots to prevent shifts
enables removal without invalidating references by index
static
dynamic
capacity may change during lifetime
growth strategy defines amortized cost and fragmentation
shrink strategy determines memory return behavior
resizing may or may not preserve pointer stability depending on contract
single type
nested or multidimensional
flat representation
hierarchical representation
mixed type
memory region accessed through multiple type interpretations
requires explicit control over layout and aliasing
common mechanisms
incorrect aliasing leads to undefined behavior
resize
append
insert
removal
deletes an element and frees its slot
strategy defines semantic cost
shift removal preserves order, breaks stability
swap removal preserves density, breaks identity
tombstones preserve identity, reduce density
array of structs
struct of arrays
each field stored in a separate array
multiple base pointers
optimal for bulk and vectorized operations
per-record access requires multiple loads
static contiguous
dynamic contiguous
stable slots contiguous
contiguous slot array
slot identity is stable
removal creates empty slots
reuse via free list
iteration must test slot occupancy
fixed blocks
unequal block sizes
per-element allocation
stable slots
logical index refers to a slot, not a position
slot identity is preserved across removals
empty slots accumulate unless reused
iteration must skip empty slots
reuse is mediated by a free list
stack-based free list
properties
consequences
embedded free list
properties
consequences
comparison
stack-based
embedded
minimal auxiliary memory
tighter coupling between storage and allocator logic
contract
design
insertion
removal
iteration
compaction
optional operation
requires emitting index remapping
array of structs
struct of arrays