Struct interval_heap::IntervalHeap [] [src]

pub struct IntervalHeap<T, C: Compare<T> = Natural<T>> { /* fields omitted */ }

A double-ended priority queue implemented with an interval heap.

It is a logic error for an item to be modified in such a way that the item's ordering relative to any other item, as determined by the heap's comparator, changes while it is in the heap. This is normally only possible through Cell, RefCell, global state, I/O, or unsafe code.

Methods

impl<T: Ord> IntervalHeap<T>
[src]

Returns an empty heap ordered according to the natural order of its items.

Examples

use interval_heap::IntervalHeap;

let heap = IntervalHeap::<u32>::new();
assert!(heap.is_empty());

Returns an empty heap with the given capacity and ordered according to the natural order of its items.

The heap will be able to hold exactly capacity items without reallocating.

Examples

use interval_heap::IntervalHeap;

let heap = IntervalHeap::<u32>::with_capacity(5);
assert!(heap.is_empty());
assert!(heap.capacity() >= 5);

impl<T, C: Compare<T>> IntervalHeap<T, C>
[src]

Returns an empty heap ordered according to the given comparator.

Returns an empty heap with the given capacity and ordered according to the given comparator.

Returns a heap containing all the items of the given vector and ordered according to the given comparator.

Returns an iterator visiting all items in the heap in arbitrary order.

Returns a reference to the smallest item in the heap.

Returns None if the heap is empty.

Returns a reference to the greatest item in the heap.

Returns None if the heap is empty.

Returns references to the smallest and greatest items in the heap.

Returns None if the heap is empty.

Returns the number of items the heap can hold without reallocation.

Reserves the minimum capacity for exactly additional more items to be inserted into the heap.

Does nothing if the capacity is already sufficient.

Note that the allocator may give the heap more space than it requests. Therefore capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

Reserves capacity for at least additional more items to be inserted into the heap.

The heap may reserve more space to avoid frequent reallocations.

Discards as much additional capacity from the heap as possible.

Removes the smallest item from the heap and returns it.

Returns None if the heap was empty.

Removes the greatest item from the heap and returns it.

Returns None if the heap was empty.

Pushes an item onto the heap.

Consumes the heap and returns its items as a vector in arbitrary order.

Consumes the heap and returns its items as a vector in sorted (ascending) order.

Returns the number of items in the heap.

Returns true if the heap contains no items.

Removes all items from the heap.

Trait Implementations

impl<T: Clone, C: Clone + Compare<T>> Clone for IntervalHeap<T, C>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T, C: Compare<T> + Default> Default for IntervalHeap<T, C>
[src]

Returns the "default value" for a type. Read more

impl<T: Ord> From<Vec<T>> for IntervalHeap<T>
[src]

Returns a heap containing all the items of the given vector and ordered according to the natural order of its items.

Examples

use interval_heap::IntervalHeap;

let heap = IntervalHeap::from(vec![5, 1, 6, 4]);
assert_eq!(heap.len(), 4);
assert_eq!(heap.min_max(), Some((&1, &6)));

impl<T: Debug, C: Compare<T>> Debug for IntervalHeap<T, C>
[src]

Formats the value using the given formatter.

impl<T, C: Compare<T> + Default> FromIterator<T> for IntervalHeap<T, C>
[src]

Creates a value from an iterator. Read more

impl<T, C: Compare<T>> Extend<T> for IntervalHeap<T, C>
[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, T: 'a + Copy, C: Compare<T>> Extend<&'a T> for IntervalHeap<T, C>
[src]

Extends a collection with the contents of an iterator. Read more

impl<T, C: Compare<T>> IntoIterator for IntervalHeap<T, C>
[src]

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

impl<'a, T, C: Compare<T>> IntoIterator for &'a IntervalHeap<T, C>
[src]

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