Expand description
§array_list
array_list implements an unrolled linked list -like datastructure with features
that combine the simplicity of a Vec and the flexibility of a LinkedList.
§Features
- Ordered sequence with index based elements access and efficient random access lookups.
- Chunked storage, which improves cache locality and reduces pointer overhead compared to traditional linked lists.
- Stable
CursorAPI similar to theLinkedListone on nightly, allowing efficient operations around a point in the list. - Dynamic growth, balancing between
VecandLinkedListcharacteristics.
§Use Cases
array_list is ideal for scenarios where:
- You need a ordered collection with random access capabilities.
- You require frequent insertions and deletions anywhere in the list.
- Memory efficiency and improved cache performance over plain LinkedList are priorities.
§Note
This crate is not related to Java’s ArrayList despite its name.
The design and functionality are entirely tailored to Rust’s ecosystem.
§Example
use array_list::ArrayList;
let mut list: ArrayList<i64, 6> = ArrayList::new();
list.push_back(2);
list.push_front(0);
list.insert(1, 1);
assert_eq!(list.front(), Some(&0));
assert_eq!(list.get(1), Some(&1));
assert_eq!(list.back(), Some(&2));
assert_eq!(list.remove(1), Some(1));
assert_eq!(list.pop_back(), Some(2));
assert_eq!(list.pop_front(), Some(0));Structs§
- Array
List - A dynamic container that combines the characteristics of a
Vecand aLinkedList. - Cursor
- A cursor over a ArrayList.
- Cursor
Mut - A cursor over a ArrayList.
- Iter
- An iterator over the elements of a ArrayList.
- IterMut
- An iterator over the elements of a ArrayList.