Crates.io | indexlist1 |
lib.rs | indexlist1 |
version | 0.1.2 |
source | src |
created_at | 2024-10-05 15:43:49.17115 |
updated_at | 2024-10-09 23:58:47.359561 |
description | A doubly linked list, backed by a vector |
homepage | https://github.com/bijanvan/indexlist |
repository | https://github.com/bijanvan/indexlist |
max_upload_size | |
id | 1398059 |
size | 85,965 |
IndexList is a high-performance, doubly-linked list implementation that allows efficient insertion, deletion, and iteration over elements. It uses std::Vec
internally and employs a generational index system to prevent dangling references.
push_back
, insert_before
, insert_after
, pop_front
, and remove
are efficient.To use IndexList, add it to your Cargo.toml
:
[dependencies]
indexlist = "0.1"
use indexlist::IndexList;
let mut list = IndexList::new();
list.push_back(5);
list.push_back(10);
assert_eq!(list.len(), 2);
if let Some(index) = list.index_of(&5) {
list.remove(index);
}
assert_eq!(list.len(), 1);
use indexlist::IndexList;
let mut list = IndexList::new();
list.push_back(1);
list.push_back(2);
list.push_back(3);
for item in &list {
println!("{}", *item);
}
// Output:
// 1
// 2
// 3
use indexlist::IndexList;
let mut list = IndexList::new();
let index = list.push_back(5);
if let Some(item) = list.get_mut(index) {
*item += 1;
}
assert_eq!(list.len(), 1);
assert_eq!(*list.get(index).unwrap(), 6);
For detailed documentation, including all methods and usage examples, refer to the IndexList API on docs.rs.
IndexList is thoroughly tested with a suite of unit tests covering various operations. You can run the tests using cargo test
:
cargo test
This ensures that all functionalities work as expected and helps maintain high code quality.
IndexList is licensed under the MIT license. See LICENSE for more details.
This crate is based on work done in https://github.com/steveklabnik/indexlist
and basically some more functions and tests were added.