tsil_cev

Crates.iotsil_cev
lib.rstsil_cev
version1.1.0
sourcesrc
created_at2020-12-28 21:14:30.085423
updated_at2021-02-06 17:03:47.133512
descriptionLinkedList on Vec
homepagehttps://github.com/mov-rax-rbx/TsilCev
repositoryhttps://github.com/mov-rax-rbx/TsilCev.git
max_upload_size
id328438
size290,173
(mov-rax-rbx)

documentation

README

TsilCev

Rust LICENSE Crates Documentation

LinkedList on Vec. Add and remove O(1) amortized. It has a similar interface to LinkedList and similar to Vec.

Example

use tsil_cev::TsilCev;

let mut tc = TsilCev::from(vec![5, 6, 7, 8, 9, 10]);
tc.push_front(4);

let mut cursor = tc.cursor_front_mut();
assert_eq!(cursor.current(), Some(&4));

cursor.move_next();
assert_eq!(cursor.current(), Some(&5));

cursor.remove();
assert_eq!(cursor.current(), Some(&6));

cursor.remove().remove().move_next_length(2);
assert_eq!(cursor.current(), Some(&10));

cursor.move_prev();
assert_eq!(cursor.current(), Some(&9));

tc.drain_filter_tsil(|x| *x % 2 == 0);
assert_eq!(tc.to_vec(), &[9]);

Comparison with LinkedList and VecDeque (thank Criterion)

VecDeque use swap_remove_back

Current Implementation

The allocator for the elements is Vec and each element has two indexes (next and previous element). When delete an item, it moves to the end, and something like pop is called. The time of addition and removal is amortized to O(1).

Optional features

serde

When this optional dependency is enabled, TsilCev implements the serde::Serialize and serde::Deserialize traits.

Commit count: 60

cargo fmt