MCPcopy Create free account
hub / github.com/douchuan/algorithm / new

Method new

src/common/priority_queue.rs:51–62  ·  view source on GitHub ↗
(cap: usize, comparator: Comparator<T>)

Source from the content-addressed store, hash-verified

49 }
50
51 fn new(cap: usize, comparator: Comparator<T>) -> Self {
52 let mut pq = Self {
53 pq: Vec::with_capacity(cap + 1),
54 n: 0,
55 comparator,
56 };
57
58 // 虽然此处初始化了0号元素, 但0号元素并不参与算法过程,
59 pq.pq.push(T::default());
60
61 pq
62 }
63
64 /// Returns true if this priority queue is empty
65 pub fn is_empty(&self) -> bool {

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected