Module memory

Source
Expand description

General purpose data structures

These are simply std::vec::Vec wrappers tuned for a specific purpose, so they are harder to misuse, or more efficient.

For example:

  • The first template argument in Array<I, T> and StackMapping<I, T> requires to specify a type that will be used for indexing. This prevents us from accidentally using an index of the wrong type.

  • If we know a good upper bound for the size of a vector we prefer to use Array<I, T>, BoundedVector<T> or StackMapping<Key, T> as they never allocate after being constructed.

  • Bounds checking can be disabled for all these vectors.

Structs§

Array
A contiguous non-growable array type with strongly-typed indexing.
BoundedVector
A contiguous but non-growable array type, using Vector
StackMapping
A combination of a BoundedVector and an Array.
Vector
A contiguous growable array type like std::vec::Vec

Traits§

HeapSpace
A trait for objects that can report their memory usage on the heap
Offset
Trait for types that can be used as an array index.

Functions§

assert_in_bounds
Check if an offset is contained in a half-open range.
format_memory_usage
Convert bytes to megabytes for readability.