#vec #container #shifted #negative-index

shifted_vec

A growable datastructure with positive and negative indexing built on top of std::vec::Vec calculating the offset automatically

3 releases

0.1.2 Jun 8, 2020
0.1.1 Jun 8, 2020
0.1.0 Jun 8, 2020

#1873 in Data structures

21 downloads per month

MIT/Apache

13KB
226 lines

shifted_vec

crates.io docs.rs CI pipeline

A growable datastructure with positive and negative indexing built on top of std::vec::Vec calculating the offset automatically.

use shifted_vec::ShiftedVec;

let mut v = ShiftedVec::with_offset_and_capacity(-2, 5);

// populate the ShiftedVec
v.push(0);
v.push(1);
v.push(2);
v.push(3);
v.push(4);

assert_eq!(5, v.len());

assert_eq!(2, v[0]);

// mutable access with index
v[0] = 5;

assert_eq!(5, v[0]);

No runtime deps