aboutsummaryrefslogtreecommitdiff
path: root/src/util/container_heap.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/util/container_heap.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/util/container_heap.c')
-rw-r--r--src/util/container_heap.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index c1d478e06..ef6bcc892 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -218,11 +218,11 @@ node_iterator (const struct GNUNET_CONTAINER_Heap *heap,
218{ 218{
219 if (node == NULL) 219 if (node == NULL)
220 return GNUNET_YES; 220 return GNUNET_YES;
221 if (GNUNET_YES != node_iterator (heap, 221 if (GNUNET_YES !=
222 node->left_child, iterator, iterator_cls)) 222 node_iterator (heap, node->left_child, iterator, iterator_cls))
223 return GNUNET_NO; 223 return GNUNET_NO;
224 if (GNUNET_YES != node_iterator (heap, 224 if (GNUNET_YES !=
225 node->right_child, iterator, iterator_cls)) 225 node_iterator (heap, node->right_child, iterator, iterator_cls))
226 return GNUNET_NO; 226 return GNUNET_NO;
227 return iterator (iterator_cls, node, node->element, node->cost); 227 return iterator (iterator_cls, node, node->element, node->cost);
228} 228}
@@ -267,9 +267,10 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap)
267 if (pos == NULL) 267 if (pos == NULL)
268 pos = heap->root; 268 pos = heap->root;
269 element = pos->element; 269 element = pos->element;
270 heap->walk_pos 270 heap->walk_pos =
271 = (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2)) 271 (0 ==
272 ? pos->right_child : pos->left_child; 272 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
273 2)) ? pos->right_child : pos->left_child;
273 return element; 274 return element;
274} 275}
275 276
@@ -290,8 +291,12 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap,
290 struct GNUNET_CONTAINER_HeapNode *parent; 291 struct GNUNET_CONTAINER_HeapNode *parent;
291 292
292 GNUNET_assert (node->parent == NULL); 293 GNUNET_assert (node->parent == NULL);
293 while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) 294 while ((heap->order == GNUNET_CONTAINER_HEAP_ORDER_MAX) ? (pos->cost >=
294 ? (pos->cost >= node->cost) : (pos->cost <= node->cost)) 295 node->
296 cost) : (pos->
297 cost <=
298 node->
299 cost))
295 { 300 {
296 /* node is descendent of pos */ 301 /* node is descendent of pos */
297 pos->tree_size += (1 + node->tree_size); 302 pos->tree_size += (1 + node->tree_size);
@@ -343,8 +348,8 @@ insert_node (struct GNUNET_CONTAINER_Heap *heap,
343 * @return node for the new element 348 * @return node for the new element
344 */ 349 */
345struct GNUNET_CONTAINER_HeapNode * 350struct GNUNET_CONTAINER_HeapNode *
346GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, 351GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *element,
347 void *element, GNUNET_CONTAINER_HeapCostType cost) 352 GNUNET_CONTAINER_HeapCostType cost)
348{ 353{
349 struct GNUNET_CONTAINER_HeapNode *node; 354 struct GNUNET_CONTAINER_HeapNode *node;
350 355
@@ -399,8 +404,7 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap)
399 } 404 }
400 GNUNET_free (root); 405 GNUNET_free (root);
401#if DEBUG 406#if DEBUG
402 GNUNET_assert (((heap->size == 0) && 407 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
403 (heap->root == NULL)) ||
404 (heap->size == heap->root->tree_size + 1)); 408 (heap->size == heap->root->tree_size + 1));
405 CHECK (heap->root); 409 CHECK (heap->root);
406#endif 410#endif
@@ -502,8 +506,7 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node)
502 GNUNET_free (node); 506 GNUNET_free (node);
503#if DEBUG 507#if DEBUG
504 CHECK (heap->root); 508 CHECK (heap->root);
505 GNUNET_assert (((heap->size == 0) && 509 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
506 (heap->root == NULL)) ||
507 (heap->size == heap->root->tree_size + 1)); 510 (heap->size == heap->root->tree_size + 1));
508#endif 511#endif
509 return ret; 512 return ret;
@@ -523,16 +526,14 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
523 GNUNET_CONTAINER_HeapCostType new_cost) 526 GNUNET_CONTAINER_HeapCostType new_cost)
524{ 527{
525#if DEBUG 528#if DEBUG
526 GNUNET_assert (((heap->size == 0) && 529 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
527 (heap->root == NULL)) ||
528 (heap->size == heap->root->tree_size + 1)); 530 (heap->size == heap->root->tree_size + 1));
529 CHECK (heap->root); 531 CHECK (heap->root);
530#endif 532#endif
531 remove_node (node); 533 remove_node (node);
532#if DEBUG 534#if DEBUG
533 CHECK (heap->root); 535 CHECK (heap->root);
534 GNUNET_assert (((heap->size == 1) && 536 GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) ||
535 (heap->root == NULL)) ||
536 (heap->size == heap->root->tree_size + 2)); 537 (heap->size == heap->root->tree_size + 2));
537#endif 538#endif
538 node->cost = new_cost; 539 node->cost = new_cost;
@@ -542,8 +543,7 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
542 insert_node (heap, heap->root, node); 543 insert_node (heap, heap->root, node);
543#if DEBUG 544#if DEBUG
544 CHECK (heap->root); 545 CHECK (heap->root);
545 GNUNET_assert (((heap->size == 0) && 546 GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
546 (heap->root == NULL)) ||
547 (heap->size == heap->root->tree_size + 1)); 547 (heap->size == heap->root->tree_size + 1));
548#endif 548#endif
549} 549}