0
2
0
... | ... |
@@ -245,48 +245,50 @@ |
245 | 245 |
TreeArray[i]=TreeArray[i+1]; |
246 | 246 |
TreeArray[i+1]=other; |
247 | 247 |
} |
248 | 248 |
fuse( TreeArray[i], TreeArray[i+1] ); |
249 | 249 |
} |
250 | 250 |
|
251 | 251 |
i = (0==(num_child % 2)) ? num_child-2 : num_child-1; |
252 | 252 |
while(i>=2) { |
253 | 253 |
if ( comp(container[TreeArray[i]].prio, |
254 | 254 |
container[TreeArray[i-2]].prio) ) { |
255 | 255 |
other=TreeArray[i]; |
256 | 256 |
TreeArray[i]=TreeArray[i-2]; |
257 | 257 |
TreeArray[i-2]=other; |
258 | 258 |
} |
259 | 259 |
fuse( TreeArray[i-2], TreeArray[i] ); |
260 | 260 |
i-=2; |
261 | 261 |
} |
262 | 262 |
minimum = TreeArray[0]; |
263 | 263 |
} |
264 | 264 |
|
265 | 265 |
if ( 0==num_child ) { |
266 | 266 |
minimum = container[minimum].child; |
267 | 267 |
} |
268 | 268 |
|
269 |
if (minimum >= 0) container[minimum].left_child = false; |
|
270 |
|
|
269 | 271 |
--num_items; |
270 | 272 |
} |
271 | 273 |
|
272 | 274 |
/// \brief Deletes \c item from the heap. |
273 | 275 |
/// |
274 | 276 |
/// This method deletes \c item from the heap, if \c item was already |
275 | 277 |
/// stored in the heap. It is quite inefficient in Pairing heaps. |
276 | 278 |
void erase (const Item& item) { |
277 | 279 |
int i=iimap[item]; |
278 | 280 |
if ( i>=0 && container[i].in ) { |
279 | 281 |
decrease( item, container[minimum].prio-1 ); |
280 | 282 |
pop(); |
281 | 283 |
} |
282 | 284 |
} |
283 | 285 |
|
284 | 286 |
/// \brief Decreases the priority of \c item to \c value. |
285 | 287 |
/// |
286 | 288 |
/// This method decreases the priority of \c item to \c value. |
287 | 289 |
/// \pre \c item must be stored in the heap with priority at least \c |
288 | 290 |
/// value relative to \c Compare. |
289 | 291 |
void decrease (Item item, const Prio& value) { |
290 | 292 |
int i=iimap[item]; |
291 | 293 |
container[i].prio=value; |
292 | 294 |
int p=container[i].parent; |
... | ... |
@@ -201,58 +201,58 @@ |
201 | 201 |
{ |
202 | 202 |
typedef KaryHeap<Prio, ItemIntMap> IntHeap; |
203 | 203 |
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
204 | 204 |
heapSortTest<IntHeap>(); |
205 | 205 |
heapIncreaseTest<IntHeap>(); |
206 | 206 |
|
207 | 207 |
typedef KaryHeap<Prio, IntNodeMap > NodeHeap; |
208 | 208 |
checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
209 | 209 |
dijkstraHeapTest<NodeHeap>(digraph, length, source); |
210 | 210 |
} |
211 | 211 |
|
212 | 212 |
// FibHeap |
213 | 213 |
{ |
214 | 214 |
typedef FibHeap<Prio, ItemIntMap> IntHeap; |
215 | 215 |
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
216 | 216 |
heapSortTest<IntHeap>(); |
217 | 217 |
heapIncreaseTest<IntHeap>(); |
218 | 218 |
|
219 | 219 |
typedef FibHeap<Prio, IntNodeMap > NodeHeap; |
220 | 220 |
checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
221 | 221 |
dijkstraHeapTest<NodeHeap>(digraph, length, source); |
222 | 222 |
} |
223 | 223 |
|
224 | 224 |
// PairingHeap |
225 |
// { |
|
226 |
// typedef PairingHeap<Prio, ItemIntMap> IntHeap; |
|
227 |
// checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
|
228 |
// heapSortTest<IntHeap>(); |
|
229 |
// heapIncreaseTest<IntHeap>(); |
|
230 |
// |
|
231 |
// typedef PairingHeap<Prio, IntNodeMap > NodeHeap; |
|
232 |
// checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
|
233 |
// dijkstraHeapTest<NodeHeap>(digraph, length, source); |
|
234 |
// } |
|
225 |
{ |
|
226 |
typedef PairingHeap<Prio, ItemIntMap> IntHeap; |
|
227 |
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
|
228 |
heapSortTest<IntHeap>(); |
|
229 |
heapIncreaseTest<IntHeap>(); |
|
230 |
|
|
231 |
typedef PairingHeap<Prio, IntNodeMap > NodeHeap; |
|
232 |
checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
|
233 |
dijkstraHeapTest<NodeHeap>(digraph, length, source); |
|
234 |
} |
|
235 | 235 |
|
236 | 236 |
// RadixHeap |
237 | 237 |
{ |
238 | 238 |
typedef RadixHeap<ItemIntMap> IntHeap; |
239 | 239 |
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
240 | 240 |
heapSortTest<IntHeap>(); |
241 | 241 |
heapIncreaseTest<IntHeap>(); |
242 | 242 |
|
243 | 243 |
typedef RadixHeap<IntNodeMap > NodeHeap; |
244 | 244 |
checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
245 | 245 |
dijkstraHeapTest<NodeHeap>(digraph, length, source); |
246 | 246 |
} |
247 | 247 |
|
248 | 248 |
// BinomHeap |
249 | 249 |
{ |
250 | 250 |
typedef BinomHeap<Prio, ItemIntMap> IntHeap; |
251 | 251 |
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>(); |
252 | 252 |
heapSortTest<IntHeap>(); |
253 | 253 |
heapIncreaseTest<IntHeap>(); |
254 | 254 |
|
255 | 255 |
typedef BinomHeap<Prio, IntNodeMap > NodeHeap; |
256 | 256 |
checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>(); |
257 | 257 |
dijkstraHeapTest<NodeHeap>(digraph, length, source); |
258 | 258 |
} |
0 comments (0 inline)