… | |
… | |
35 | |
35 | |
36 | |
36 | |
37 | // DANGER !! !! |
37 | // DANGER !! !! |
38 | // DANGER !! !! |
38 | // DANGER !! !! |
39 | // DANGER !! !! |
39 | // DANGER !! !! |
40 | #include "../debug.h" |
40 | // #include "../debug.h" |
41 | // DANGER !! !! |
41 | // DANGER !! !! |
42 | // DANGER !! !! |
42 | // DANGER !! !! |
43 | // DANGER !! !! |
43 | // DANGER !! !! |
44 | |
44 | |
45 | #define swap(type, a, b) \ |
45 | #define swap(type, a, b) \ |
… | |
… | |
237 | struct fibheap_el * |
237 | struct fibheap_el * |
238 | fh_insertkey(struct fibheap *h, int key, void *data) |
238 | fh_insertkey(struct fibheap *h, int key, void *data) |
239 | { |
239 | { |
240 | struct fibheap_el *x; |
240 | struct fibheap_el *x; |
241 | |
241 | |
242 | dbg(0, "RR_SEG_DEBUG:fh:001\n"); |
|
|
243 | |
|
|
244 | if ((x = fhe_newelem()) == NULL) |
242 | if ((x = fhe_newelem()) == NULL) |
245 | { |
243 | { |
246 | dbg(0, "RR_SEG_DEBUG:fh:ret-001\n"); |
|
|
247 | return NULL; |
244 | return NULL; |
248 | } |
245 | } |
249 | |
246 | |
250 | dbg(0, "RR_SEG_DEBUG:fh:002 x=%p key=%d data=%p\n", x, key, data); |
|
|
251 | /* just insert on root list, and make sure it's not the new min */ |
247 | /* just insert on root list, and make sure it's not the new min */ |
252 | x->fhe_data = data; |
248 | x->fhe_data = data; |
253 | x->fhe_key = key; |
249 | x->fhe_key = key; |
254 | |
250 | |
255 | dbg(0, "RR_SEG_DEBUG:fh:003 h=%p x=%p\n", h, x); |
|
|
256 | fh_insertel(h, x); |
251 | fh_insertel(h, x); |
257 | dbg(0, "RR_SEG_DEBUG:fh:004 x=%p\n", x); |
|
|
258 | |
252 | |
259 | return x; |
253 | return x; |
260 | } |
254 | } |
261 | |
255 | |
262 | int |
256 | int |
… | |
… | |
268 | } |
262 | } |
269 | |
263 | |
270 | int |
264 | int |
271 | fh_replacekey(struct fibheap *h, struct fibheap_el *x, int key) |
265 | fh_replacekey(struct fibheap *h, struct fibheap_el *x, int key) |
272 | { |
266 | { |
273 | dbg(0, "RR_SEG_DEBUG:fh_rpl:000\n"); |
|
|
274 | |
|
|
275 | |
267 | |
276 | int ret = 0; |
268 | int ret = 0; |
277 | |
|
|
278 | dbg(0, "RR_SEG_DEBUG:fh_rpl:001 x=%p key=%d\n", x, key); |
|
|
279 | dbg(0, "RR_SEG_DEBUG:fh_rpl:002 x->fhe_key=%d\n", x->fhe_key); |
|
|
280 | |
269 | |
281 | ret = x->fhe_key; |
270 | ret = x->fhe_key; |
282 | (void)fh_replacekeydata(h, x, key, x->fhe_data); |
271 | (void)fh_replacekeydata(h, x, key, x->fhe_data); |
283 | |
|
|
284 | dbg(0, "RR_SEG_DEBUG:fh_rpl:003 x->fhe_data=%p\n", x->fhe_data); |
|
|
285 | |
272 | |
286 | return ret; |
273 | return ret; |
287 | } |
274 | } |
288 | |
275 | |
289 | #include <stdio.h> |
276 | #include <stdio.h> |