Test of union method, of class FibHeap.
()
| 87 | * Test of union method, of class FibHeap. |
| 88 | */ |
| 89 | @Test |
| 90 | public void testUnion() |
| 91 | { |
| 92 | System.out.println("union"); |
| 93 | FibHeap<String> h1 = new FibHeap<String>(); |
| 94 | FibHeap<String> h2 = new FibHeap<String>(); |
| 95 | |
| 96 | double value = 0.0; |
| 97 | int counter= 0; |
| 98 | List<String> added = new ArrayList<String>(); |
| 99 | for(char c = 'A'; c <= 'Z'; c++) |
| 100 | { |
| 101 | counter++; |
| 102 | String s = Character.toString(c); |
| 103 | if(c % 2 == 0) |
| 104 | h1.insert(s, value--); |
| 105 | else |
| 106 | h2.insert(s, value--); |
| 107 | added.add(0, s); |
| 108 | |
| 109 | // if(c % 2 == 0) |
| 110 | // h1.insert(s, value++); |
| 111 | // else |
| 112 | // h2.insert(s, value++); |
| 113 | // added.add(s); |
| 114 | |
| 115 | } |
| 116 | |
| 117 | FibHeap<String> heap = FibHeap.union(h1, h2); |
| 118 | assertEquals(counter, heap.size()); |
| 119 | |
| 120 | counter = 0; |
| 121 | while(heap.size() > 0) |
| 122 | { |
| 123 | String s = heap.removeMin().value; |
| 124 | assertEquals(added.get(counter), s); |
| 125 | counter++; |
| 126 | } |
| 127 | |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Test of getMinKey method, of class FibHeap. |