Crates.io | graph-arena |
lib.rs | graph-arena |
version | 0.1.0 |
source | src |
created_at | 2020-11-13 14:34:10.371045 |
updated_at | 2020-11-13 14:34:10.371045 |
description | Collection type to store immutable graph structures efficiently |
homepage | |
repository | https://github.com/nilsmartel/graph-arena |
max_upload_size | |
id | 311958 |
size | 4,121 |
Collection type to store immutable graph data efficiently. Avoids heap clusturing, enforces locality and reduces the need for copying all together.
In recursive data structures, one often encounters code like this:
struct Expression {
Add(Box<Expression>, Box<Expression>),
// ...
}
In the long run one encounters several problems with this approach:
Now, allocations are something we'd like to avoid as much as possible;
alloc
is an expensive operation.
That's why a Vec<T>
allocates more memory, than it (might) use. So no reallocation of data is required each time we push more data.
Furthermore we desire related data to live in near by memory locations: Modern CPUs are heavily modified to take advantage of locality, that makes Vec<T>
an insanely fast data strucutre!