Crates.io | array_list |
lib.rs | array_list |
version | |
source | src |
created_at | 2024-11-28 22:23:53.553614 |
updated_at | 2024-11-29 16:21:21.944928 |
description | A dynamic container that combines the characteristics of a Vec and a LinkedList |
homepage | |
repository | https://github.com/daddinuz/array_list |
max_upload_size | |
id | 1465024 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
ArrayList
is a Rust crate that implements an unrolled linked list powered by a XOR linked list as its underlying structure.
It combines features of both a Vec
and a LinkedList
, offering efficient sequential access with reduced pointer overhead compared
to a traditional doubly linked list.
This crate is designed to handle dynamic collections efficiently, particularly in scenarios where frequent insertions, deletions, or iterations are required.
Vec
(compact, cache-friendly storage) and a LinkedList
(efficient insertions and deletions).get
methods.Vec
: While ArrayList
provides index-based access, it requires traversing the list, making it less efficient than Vec
for frequent random access.unsafe
code for managing memory and pointers. However, it is extensively tested.Vec
or LinkedList
: The additional logic for node splitting, merging, and XOR-linked traversal increases complexity compared to simpler collections.Add array_list
to your Cargo.toml
:
cargo add array_list
or edit your Cargo.toml manually by adding:
[dependencies]
array_list = "0.2"
use array_list::ArrayList;
fn main() {
let mut list: ArrayList<i32, 2> = ArrayList::new();
// Insert elements
list.push_back(1);
list.push_back(3);
list.push_front(0);
list.insert(1, 2);
// Access elements
println!("front: {:?}", list.front()); // Some(0)
println!("back: {:?}", list.back()); // Some(3)
// Remove elements
assert_eq!(list.pop_front(), Some(0));
assert_eq!(list.pop_back(), Some(3));
}
This crate contains unsafe
code to achieve optimal performance and memory management.
However:
Contributions are welcome! Whether it’s improving documentation, fixing bugs, or suggesting new features, feel free to open an issue or submit a pull request (PR).
When contributing, please ensure:
cargo fmt
.unsafe
code introduced.By contributing, you agree that your contributions will be licensed under the terms of the MIT license.
This crate is licensed under the MIT License. You are free to use, modify, and distribute it under the terms of the license.