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

Method sink

src/common/priority_queue.rs:107–120  ·  view source on GitHub ↗
(&mut self, mut k: usize)

Source from the content-addressed store, hash-verified

105 }
106
107 fn sink(&mut self, mut k: usize) {
108 let n = self.n;
109 while 2 * k <= n {
110 let mut j = 2 * k;
111 if j < n && self.compare(j, j + 1) {
112 j += 1;
113 }
114 if !self.compare(k, j) {
115 break;
116 }
117 self.pq.swap(k, j);
118 k = j;
119 }
120 }
121
122 fn compare(&self, i: usize, j: usize) -> bool {
123 (self.comparator)(&self.pq[i], &self.pq[j])

Callers 1

dequeueMethod · 0.80

Calls 2

compareMethod · 0.80
exchMethod · 0.80

Tested by

no test coverage detected