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 raw_pop(&mut self) -> T
pub fn raw_pop(&mut self) -> T
Like Self::pop() but without the Option wrapper.
Will panic if the array is empty.
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
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.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the array, removing all values and deallocating all leaves.
§Time complexity
O(N) if elements are droppable, otherwise O(√N)
Sourcepub fn sort_unstable_by<F>(&mut self, compare: F)
pub fn sort_unstable_by<F>(&mut self, compare: F)
Sorts the slice in ascending order with a comparison function, without preserving the initial order of equal elements.
This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate), and O(n * log(n)) worst-case.
Implements the standard heapsort algorithm.
Sourcepub fn dedup_by<F>(&mut self, same_bucket: F)
pub fn dedup_by<F>(&mut self, same_bucket: F)
Removes all but the first of consecutive elements in the array satisfying a given equality relation.
The same_bucket function is passed references to two elements from the
array and must determine if the elements compare equal. The elements are
passed in reverse order from their order in the array, so if
same_bucket(a, b) returns true, a is removed.
If the array is sorted, this removes all duplicates.
Sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all the elements of other into self, leaving other empty.