Struct btree_vec::BTreeVec

source ·
pub struct BTreeVec<T, const B: usize = 12, A: Allocator = Global> { /* private fields */ }
Expand description

A growable array (vector) implemented as a B+ tree.

Provides non-amortized O(log n) random accesses, insertions, and removals, and O(n) iteration.

B is the branching factor. It must be at least 3. The standard library uses a value of 6 for its B-tree structures. Larger values are better when T is smaller.

Implementations§

Creates a new BTreeVec. Note that this function is implemented only for the default value of B; see Self::create for an equivalent that works with all values of B.

Creates a new BTreeVec with the given allocator. Note that this function is implemented only for the default value of B; see Self::create_in for an equivalent that works with all values of B.

Creates a new BTreeVec. This function exists because BTreeVec::new is implemented only for the default value of B.

Creates a new BTreeVec with the given allocator. This function exists because BTreeVec::new_in is implemented only for the default value of B.

Gets the length of the vector.

Checks whether the vector is empty.

Gets the item at index, or None if no such item exists.

Gets a mutable reference to the item at index, or None if no such item exists.

Gets the first item in the vector, or None if the vector is empty.

Gets a mutable reference to the first item in the vector, or None if the vector is empty.

Gets the last item in the vector, or None if the vector is empty.

Gets a mutable reference to the last item in the vector, or None if the vector is empty.

Inserts item at index.

Panics

Panics if index is greater than self.len().

Inserts item at the end of the vector.

Removes and returns the item at index.

Panics

Panics if index is not less than self.len().

Removes and returns the last item in the vector, or None if the vector is empty.

Gets an iterator that returns references to each item in the vector.

Gets an iterator that returns mutable references to each item in the vector.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Executes the destructor for this type. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.