Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

spell interleave correctly. add check that deleting the last item res…

…ults in an empty heap
  • Loading branch information...
commit b71b64a0af2fff4a25e0f47eb4bd80967735d8a4 1 parent dc52dc1
Steve Jenson authored December 08, 2012

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  pairing_heap.rs
12  pairing_heap.rs
@@ -106,7 +106,6 @@ impl<E: Copy Eq Ord> PairingHeap<E> : Heap<E> {
106 106
 
107 107
   pure fn merge_pairs(heaps: @List<PairingHeap<E>>) -> PairingHeap<E> {
108 108
     match heaps {
109  
-      // Why are @-signs required for pattern matching here?
110 109
       @Cons(a, @Cons(b, xs)) => {a.merge(b).merge(self.merge_pairs(xs))}
111 110
       @Cons(elem, @Nil) => {elem}
112 111
       @Nil => {Empty()}
@@ -126,6 +125,15 @@ fn test_heap_create() {
126 125
 }
127 126
 
128 127
 #[test]
  128
+fn test_delete_last_item() {
  129
+  let v1 = PairingHeap(1);
  130
+  assert(!v1.is_empty());
  131
+
  132
+  let (_, v2) = v1.delete_min();
  133
+  assert(v2.is_empty());
  134
+}
  135
+
  136
+#[test]
129 137
 fn test_heap_insert() {
130 138
   let v1 = PairingHeap(10);
131 139
   let v2 = v1.insert(1);
@@ -141,7 +149,7 @@ fn test_heap_insert() {
141 149
 }
142 150
 
143 151
 #[test]
144  
-fn test_heap_insert_delete_interleved() {
  152
+fn test_heap_insert_delete_interleaved() {
145 153
   let v1 = PairingHeap(10);
146 154
   let (a, v2) = v1.delete_min();
147 155
   assert(a == Some(10));

0 notes on commit b71b64a

Please sign in to comment.
Something went wrong with that request. Please try again.