pub struct HashedArrayTree<T> { /* private fields */ }Expand description
Hashed Array Tree (HAT) described by Edward Sitarski.
Implementations§
Source§impl<T> HashedArrayTree<T>
impl<T> HashedArrayTree<T>
Sourcepub fn push_within_capacity(&mut self, value: T) -> Result<(), T>
pub fn push_within_capacity(&mut self, value: T) -> Result<(), T>
Appends an element if there is sufficient spare capacity, otherwise an error is returned with the element.
§Time complexity
O(N) in the worst case (expand).
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the last element from the array and returns it, or None if the
array is empty.
§Time complexity
O(N) in the worst case (shrink).
Sourcepub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T>
pub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option<T>
Removes and returns the last element from an array if the predicate
returns true, or None`` if the predicate returns false`` or the array
is empty (the predicate will not be called in that case).
§Time complexity
O(N) in the worst case (shrink).
Sourcepub fn swap_remove(&mut self, index: usize) -> T
pub fn swap_remove(&mut self, index: usize) -> T
Removes an element from the array and returns it.
The removed element is replaced by the last element of the array.
This does not preserve ordering of the remaining elements.
§Time complexity
O(N) in the worst case (shrink).
pub fn iter(&self) -> ArrayIter<'_, T> ⓘ
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the total number of elements the array can hold without reallocating.
§Time complexity
Constant time.