diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-01-24 14:46:09 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-01-24 14:46:09 -0500 |
| commit | d912d53ea9921c4fc9044c657ddcb3e044617fa9 (patch) | |
| tree | 2730d7a4a42e68b1e40568416b2e8c27c352b38b /src/libstd/priority_queue.rs | |
| parent | e8f4da78e78238d7a24dc452302a4c1f113f0e2a (diff) | |
| download | rust-d912d53ea9921c4fc9044c657ddcb3e044617fa9.tar.gz rust-d912d53ea9921c4fc9044c657ddcb3e044617fa9.zip | |
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(); } |
