@@ -47,9 +47,6 @@ impl <T: Ord> PriorityQueue<T> {
47
47
if self . is_empty ( ) { None } else { Some ( self . top ( ) ) }
48
48
}
49
49
50
- /// Returns true if a queue contains some elements
51
- pure fn is_not_empty ( & self ) -> bool { self . data . is_not_empty ( ) }
52
-
53
50
/// Returns the number of elements the queue can hold without reallocating
54
51
pure fn capacity ( & self ) -> uint { vec:: capacity ( & self . data ) }
55
52
@@ -62,7 +59,7 @@ impl <T: Ord> PriorityQueue<T> {
62
59
/// Pop the greatest item from the queue - fails if empty
63
60
fn pop ( & mut self ) -> T {
64
61
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 ) ; }
66
63
item
67
64
}
68
65
@@ -80,7 +77,7 @@ impl <T: Ord> PriorityQueue<T> {
80
77
/// Optimized version of a push followed by a pop
81
78
fn push_pop ( & mut self , item : T ) -> T {
82
79
let mut item = item;
83
- if self . is_not_empty ( ) && self . data [ 0 ] > item {
80
+ if ! self . is_empty ( ) && self . data [ 0 ] > item {
84
81
item <-> self . data [ 0 ] ;
85
82
self . siftdown ( 0 ) ;
86
83
}
@@ -189,7 +186,7 @@ mod tests {
189
186
let data = ~[ 2 , 4 , 6 , 2 , 1 , 8 , 10 , 3 , 5 , 7 , 0 , 9 , 1 ] ;
190
187
let mut sorted = merge_sort ( data, le) ;
191
188
let mut heap = from_vec ( data) ;
192
- while heap. is_not_empty ( ) {
189
+ while ! heap. is_empty ( ) {
193
190
assert * heap. top ( ) == sorted. last ( ) ;
194
191
assert heap. pop ( ) == sorted. pop ( ) ;
195
192
}
0 commit comments