Crates.io | iterlist |
lib.rs | iterlist |
version | 0.5.0 |
source | src |
created_at | 2024-08-02 21:46:49.487624 |
updated_at | 2024-11-25 22:46:04.491596 |
description | Linked list with a cursor based api |
homepage | |
repository | https://github.com/slbsh/iterlist |
max_upload_size | |
id | 1323783 |
size | 80,421 |
It's a doubly linked list with a cursor based api.
also an iterator!
O(1)
pretty much everything (at and around the cursor).
Originally made it for Shard, but thought it could be useful to someone else.
Sign here to join the linked-list uprising against the Vec
tyranny!
☑
Now Featuring: the atomic
module!
Are you bored of performant data structures?
Do you want to do some lock-free shenanigans?
slaps hood
Well this baby's now Send + Sync
Using Result<Option<Result<Result ...
use iterlist::IterList;
let mut list = IterList::new();
list.push_prev(-1);
list.push_next(1);
list.push_next(2);
list.push_next(3);
assert_eq!(format!("{:?}", list), "[-1, 1, 2, 3]");
list.move_to(2);
assert_eq!(list.get_cursor(), Some(&2));
list.move_by(-2);
assert_eq!(list.index(), 0);
let mut cursor = list.as_cursor();
assert_eq!(cursor.next(), Some(&-1));
assert_eq!(cursor.next(), Some(&1));
assert_eq!(list.get(1), Some(&1));
list.move_by(2);
let (elem, _) = list.consume_forward().unwrap();
assert_eq!(elem, 2);
assert_eq!(format!("{:?}", list), "[-1, 1, 3]");
let num = list.fold(0, |acc, elem| acc + elem);
assert_eq!(num, 3);
IterList
?std::collections::VecDeque
)std::collections::LinkedList
in most cases!append
- append another list to the end of this one.prepend
- prepend another list to the start of this one.drain
- remove a range of elements (around the cursor) from the list.splice
- replace a range of elements (around the cursor) with another list.DoubleEndedIterator
for Cursor
.feature(atomic)
- atomic IterList and Cursor.feature(pool)
- semi-pool allocated list for grouping elements into contiguous memory.feature(no_std)
- no std support.feature(serde)
- serde support.Feel free to add any of these if ya wanna!