pub struct MinMaxHeap<T>(_);
Expand description

A double-ended priority queue.

Most operations are O(log n).

Implementations

Creates a new, empty MinMaxHeap.

O(1).

Creates a new, empty MinMaxHeap with space allocated to hold len elements.

O(n).

The number of elements in the heap.

O(1).

Is the heap empty?

O(1).

Adds an element to the heap.

Amortized O(log n); worst-case O(n) when the backing vector needs to grow.

Gets a reference to the minimum element, if any.

O(1).

Gets a reference to the maximum element, if any.

O(1).

Removes the minimum element, if any.

O(log n).

Removes the maximum element, if any.

O(log n).

Pushes an element, then pops the minimum element.

Unlike a push followed by a pop, this combined operation will not allocate.

O(log n).

Pushes an element, then pops the maximum element in an optimized fashion.

Unlike a push followed by a pop, this combined operation will not allocate.

O(log n).

Pops the minimum, then pushes an element in an optimized fashion.

O(log n).

Pops the maximum, then pushes an element in an optimized fashion.

O(log n).

Returns an ascending (sorted) vector, reusing the heap’s storage.

O(n log n).

Returns an descending (sorted) vector, reusing the heap’s storage.

O(n log n).

Drops all items from the heap.

O(n)

The number of elements the heap can hold without reallocating.

O(1)

Reserves the minimum capacity for exactly additional more elements to be inserted in the given MinMaxHeap.

O(n)

Panics

Panics if the new capacity overflows usize.

Reserves the minimum capacity for at least additional more elements to be inserted in the given MinMaxHeap.

O(n)

Panics

Panics if the new capacity overflows usize.

Discards extra capacity.

O(n)

Consumes the MinMaxHeap and returns its elements in a vector in arbitrary order.

O(n)

Returns a borrowing iterator over the min-max-heap’s elements in arbitrary order.

O(1) on creation, and O(1) for each next() operation.

Returns a draining iterator over the min-max-heap’s elements in arbitrary order.

O(1) on creation, and O(1) for each next() operation.

Returns a draining iterator over the min-max-heap’s elements in ascending (min-first) order.

O(1) on creation, and O(log n) for each next() operation.

Returns a draining iterator over the min-max-heap’s elements in descending (max-first) order.

O(1) on creation, and O(log n) for each next() operation.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Converts to this type from the input type.
Creates a value from an iterator. 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
Serialize this value into the given Serde serializer. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.