diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-01-24 12:16:03 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-01-24 12:16:03 -0800 |
| commit | e43cff6657b5ba4245480ede5230e3f00aa52185 (patch) | |
| tree | 627cbbae801ec76dd1c97083031dd5effc7a1006 /src/libstd/priority_queue.rs | |
| parent | 86b8bf37bbd5c83953933c9c38a20567843c3a7f (diff) | |
| parent | d912d53ea9921c4fc9044c657ddcb3e044617fa9 (diff) | |
| download | rust-e43cff6657b5ba4245480ede5230e3f00aa52185.tar.gz rust-e43cff6657b5ba4245480ede5230e3f00aa52185.zip | |
Merge pull request #4616 from thestinger/priority_queue
remove is_not_empty method from PriorityQueue
Diffstat (limited to 'src/libstd/priority_queue.rs')
| -rw-r--r-- | src/libstd/priority_queue.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index b5b30599d48..a348026f072 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -47,9 +47,6 @@ impl <T: Ord> PriorityQueue<T> { if self.is_empty() { None } else { Some(self.top()) } } - /// Returns true if a queue contains some elements - pure fn is_not_empty(&self) -> bool { self.data.is_not_empty() } - /// Returns the number of elements the queue can hold without reallocating pure fn capacity(&self) -> uint { vec::capacity(&self.data) } @@ -62,7 +59,7 @@ impl <T: Ord> PriorityQueue<T> { /// Pop the greatest item from the queue - fails if empty fn pop(&mut self) -> T { let mut item = self.data.pop(); - if self.is_not_empty() { item <-> self.data[0]; self.siftdown(0); } + if !self.is_empty() { item <-> self.data[0]; self.siftdown(0); } item } @@ -80,7 +77,7 @@ impl <T: Ord> PriorityQueue<T> { /// Optimized version of a push followed by a pop fn push_pop(&mut self, item: T) -> T { let mut item = item; - if self.is_not_empty() && self.data[0] > item { + if !self.is_empty() && self.data[0] > item { item <-> self.data[0]; self.siftdown(0); } @@ -189,7 +186,7 @@ mod tests { let data = ~[2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1]; let mut sorted = merge_sort(data, le); let mut heap = from_vec(data); - while heap.is_not_empty() { + while !heap.is_empty() { assert *heap.top() == sorted.last(); assert heap.pop() == sorted.pop(); } |
