docs

v0.1.0 문서를 보고 있습니다. 이 버전은 더 이상 지원하지 않습니다. 최신 릴리스: v0.1.3 →

core::collections::heap

이 페이지의 내용

API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.

BinaryHeap<T>, a priority queue over a List laid out as an implicit binary tree. new() pops the greatest item first; by_ordering(cmp) pops the greatest by cmp.

Structs

BinaryHeapSource

pub struct BinaryHeap<T>

A priority queue: new() pops the greatest item first, by_ordering(cmp) the greatest by cmp.

  • pub const fn new() -> BinaryHeap<T>§

    Source

    A max-heap.

  • pub const fn by_ordering(cmp: fn(T, T) -> core::cmp::Ordering + Send) -> BinaryHeap<T>§

    Source

    A heap whose top is the greatest item by cmp, as new() is by Ord::cmp: by_ordering(|a, b| b.cmp(a)) pops the least first.

  • pub const fn len(self) -> usize§

    Source

    The number of items.

  • pub const fn is_empty(self) -> bool§

    Source

    true when the heap holds no item.

  • pub const fn peek(self) -> T | none§

    Source

    The top item.

  • pub const fn push(self, x: T)§

    Source

    Add x; O(log n).

  • pub const fn pop(self) -> T | none§

    Source

    Remove and return the top item; O(log n).

  • pub const fn clear(self)§

    Source

    Drop every item.

  • pub const fn retain(self, keep: fn(T) -> bool)§

    Source

    Keep only the items keep accepts, in place; O(n).

  • pub const fn iter(self) -> HeapIter<T>§

    Source

    Every item, in no particular order.

Trait implementations 6

HeapIterSource

pub struct HeapIter<T>

The items of a heap, in no particular order.

Trait implementations 3