1 unstable release
0.1.0 | Mar 4, 2019 |
---|
#8 in #gap
14KB
193 lines
GapVec
This library implements gap vector.
It is well known that this data structure suits editor, actually be also used in emacs. You can Insert or Delete text efficiently.
lib.rs
:
A contiguous growable array type with heap-allocated contens and gap.
It's written GapVec<T>
but pronounced 'gap vector'.
Examples
You can explicitly create a GapVec<T>
with new
:
use gap_vec::GapVec;
let mut gap_vec: GapVec<i32> = GapVec::new();
You can insert
values (which will grow the gap vector as needed):
use gap_vec::GapVec;
let mut gap_vec = GapVec::new();
gap_vec.insert("onion".to_string());
You can remove
values in much the same way:
use gap_vec::GapVec;
let mut gap_vec = GapVec::new();
gap_vec.insert("foo".to_string());
gap_vec.set_position(0);
assert_eq!(gap_vec.remove().unwrap(), "foo".to_string());