Skip to content

Commit d912d53

Browse files
committed
remove is_not_empty method from PriorityQueue
1 parent e8f4da7 commit d912d53

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/libstd/priority_queue.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ impl <T: Ord> PriorityQueue<T> {
4747
if self.is_empty() { None } else { Some(self.top()) }
4848
}
4949

50-
/// Returns true if a queue contains some elements
51-
pure fn is_not_empty(&self) -> bool { self.data.is_not_empty() }
52-
5350
/// Returns the number of elements the queue can hold without reallocating
5451
pure fn capacity(&self) -> uint { vec::capacity(&self.data) }
5552

@@ -62,7 +59,7 @@ impl <T: Ord> PriorityQueue<T> {
6259
/// Pop the greatest item from the queue - fails if empty
6360
fn pop(&mut self) -> T {
6461
let mut item = self.data.pop();
65-
if self.is_not_empty() { item <-> self.data[0]; self.siftdown(0); }
62+
if !self.is_empty() { item <-> self.data[0]; self.siftdown(0); }
6663
item
6764
}
6865

@@ -80,7 +77,7 @@ impl <T: Ord> PriorityQueue<T> {
8077
/// Optimized version of a push followed by a pop
8178
fn push_pop(&mut self, item: T) -> T {
8279
let mut item = item;
83-
if self.is_not_empty() && self.data[0] > item {
80+
if !self.is_empty() && self.data[0] > item {
8481
item <-> self.data[0];
8582
self.siftdown(0);
8683
}
@@ -189,7 +186,7 @@ mod tests {
189186
let data = ~[2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
190187
let mut sorted = merge_sort(data, le);
191188
let mut heap = from_vec(data);
192-
while heap.is_not_empty() {
189+
while !heap.is_empty() {
193190
assert *heap.top() == sorted.last();
194191
assert heap.pop() == sorted.pop();
195192
}

0 commit comments

Comments
 (0)