Columned
A single, contiguous, allocation for multiple arrays. Meant to allocate multiple arrays, that live the same lifetimes. This reduces multiple allocations, to a single one. This crate may facilitates the implementation of columnar data structures.
Example
use ;
Working Principle
Columned manages a contiguous allocation of memory. Each Coulmn have a pointer to this contiguous allocation. The following figure illustrates the working principle.
Columned
+--------+--------+
| 0x0123 | ... |
+--------+--------+
ptr
|
V
Heap +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 0.1 | 3.2 | 5 | 7 | 20 | 6 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
^ ^
| |
ptr len ptr len
+--------+--------+ +--------+--------+
| 0x0123 | 2 | | 0x012b | 4 |
+--------+--------+ +--------+--------+
Column<f32> Column<u16>
This also means that the user has to ensure that Columned outlives the Columns that uses its managed memory.