Skip to content

Commit d5d606b

Browse files
thestingerbrson
authored andcommitted
---
yaml --- r: 35575 b: refs/heads/master c: 04df723 h: refs/heads/master i: 35573: 02dbe4d 35571: b41d4a1 35567: 5260849 v: v3
1 parent d8e2ff6 commit d5d606b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7bd0d7155495486b35c67772eb96c930af2cf7d0
2+
refs/heads/master: 04df72361950df210ccf2534c0af421078aabc0a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libstd/priority_queue.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl <T: Copy Ord> PriorityQueue<T> {
3939
/// Pop the greatest item from the queue - fails if empty
4040
fn pop(&mut self) -> T {
4141
let mut item = self.data.pop();
42-
if self.is_not_empty() { item <-> self.data[0]; self.siftup(0); }
42+
if self.is_not_empty() { item <-> self.data[0]; self.siftdown(0); }
4343
item
4444
}
4545

@@ -51,15 +51,15 @@ impl <T: Copy Ord> PriorityQueue<T> {
5151
/// Push an item onto the queue
5252
fn push(&mut self, item: T) {
5353
self.data.push(item);
54-
self.siftdown(0, self.len() - 1);
54+
self.siftup(0, self.len() - 1);
5555
}
5656

5757
/// Optimized version of a push followed by a pop
5858
fn push_pop(&mut self, item: T) -> T {
5959
let mut item = item;
6060
if self.is_not_empty() && self.data[0] > item {
6161
item <-> self.data[0];
62-
self.siftup(0);
62+
self.siftdown(0);
6363
}
6464
item
6565
}
@@ -68,7 +68,7 @@ impl <T: Copy Ord> PriorityQueue<T> {
6868
fn replace(&mut self, item: T) -> T {
6969
let mut item = item;
7070
item <-> self.data[0];
71-
self.siftup(0);
71+
self.siftdown(0);
7272
item
7373
}
7474

@@ -82,7 +82,7 @@ impl <T: Copy Ord> PriorityQueue<T> {
8282
while end > 1 {
8383
end -= 1;
8484
q.data[end] <-> q.data[0];
85-
unsafe { q.siftup_range(0, end) } // purity-checking workaround
85+
unsafe { q.siftdown_range(0, end) } // purity-checking workaround
8686
}
8787
q.to_vec()
8888
}
@@ -92,12 +92,12 @@ impl <T: Copy Ord> PriorityQueue<T> {
9292
let mut n = q.len() / 2;
9393
while n > 0 {
9494
n -= 1;
95-
unsafe { q.siftup(n) }; // purity-checking workaround
95+
unsafe { q.siftdown(n) }; // purity-checking workaround
9696
}
9797
q
9898
}
9999

100-
priv fn siftdown(&mut self, startpos: uint, pos: uint) {
100+
priv fn siftup(&mut self, startpos: uint, pos: uint) {
101101
let mut pos = pos;
102102
let newitem = self.data[pos];
103103

@@ -114,7 +114,7 @@ impl <T: Copy Ord> PriorityQueue<T> {
114114
self.data[pos] = newitem;
115115
}
116116

117-
priv fn siftup_range(&mut self, pos: uint, endpos: uint) {
117+
priv fn siftdown_range(&mut self, pos: uint, endpos: uint) {
118118
let mut pos = pos;
119119
let startpos = pos;
120120
let newitem = self.data[pos];
@@ -131,11 +131,11 @@ impl <T: Copy Ord> PriorityQueue<T> {
131131
childpos = 2 * pos + 1;
132132
}
133133
self.data[pos] = newitem;
134-
self.siftdown(startpos, pos);
134+
self.siftup(startpos, pos);
135135
}
136136

137-
priv fn siftup(&mut self, pos: uint) {
138-
self.siftup_range(pos, self.len());
137+
priv fn siftdown(&mut self, pos: uint) {
138+
self.siftdown_range(pos, self.len());
139139
}
140140
}
141141

0 commit comments

Comments
 (0)