[−][src]Module rate_common::memory
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>andStackMapping<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>orStackMapping<Key, T>as they never allocate after being constructed. -
Bounds checking can be disabled for all these vectors.
-
SmallVectordoes not allocate anything when it contains only one or no elements. This can save memory when there are lots of vectors of size one.
Structs
| Array | A contiguous non-growable array type with strongly-typed indexing. |
| BoundedVector | A contiguous but non-growable array type, using |
| StackMapping | A combination of a |
| Vector | A contiguous growable array type like |
Enums
| SmallVector | A |
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. |