Crates.io | segvec |
lib.rs | segvec |
version | 0.2.0 |
source | src |
created_at | 2021-06-30 04:04:04.891009 |
updated_at | 2023-07-31 04:35:45.2254 |
description | SegVec data structure for rust. Similar to Vec, but allocates memory in chunks of increasing size |
homepage | |
repository | https://github.com/mccolljr/segvec/ |
max_upload_size | |
id | 416501 |
size | 104,746 |
This crate provides the SegVec
data structure.
It is similar to Vec
, but allocates memory in chunks of increasing size, referred to as
"segments". This involves a few trade-offs:
push
operations even if the SegVec
must grow.insert
, remove
, and drain
, are much slower) for a SegVec
than for a Vec
(multiple pointer dereferences, mapping indices to (segment, offset)
pairs)&[T]
or &mut [T]
), though slice
and slice_mut
are availableVec
whose size fluctuates between very large and very small throughout the life of the program.Vec
and would benefit from stable references to the elementssmall-vec
- Uses SmallVec
instead of Vec
to store the list of segments, allowing the first few segment headers to live on the stack. Can speed up access for small SegVec
values.thin-segments
- Uses ThinVec
instead of Vec
to store the data for each segment, meaning that each segment header takes up the space of a single usize
, rathern than 3 when using Vec
.License: MIT