aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_container_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-20 07:21:37 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-20 07:21:37 +0000
commit2c784744bc7a15956c7ee766b5914559279ee83f (patch)
treea5442cdc11c0e8c4954faa25de73510716a7349e /src/include/gnunet_container_lib.h
parent7e7e68018805b6566060d063d81f7ae5e5bb03e4 (diff)
downloadgnunet-2c784744bc7a15956c7ee766b5914559279ee83f.tar.gz
gnunet-2c784744bc7a15956c7ee766b5914559279ee83f.zip
formatting
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r--src/include/gnunet_container_lib.h67
1 files changed, 36 insertions, 31 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index b9ce80d95..97bce967e 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -446,11 +446,11 @@ struct GNUNET_CONTAINER_MultiHashMap;
446 */ 446 */
447enum GNUNET_CONTAINER_MultiHashMapOption 447enum GNUNET_CONTAINER_MultiHashMapOption
448{ 448{
449
449 /** 450 /**
450 * If a value with the given key exists, replace it. 451 * If a value with the given key exists, replace it. Note that the
451 * Note that the old value would NOT be freed 452 * old value would NOT be freed by replace (the application has to
452 * by replace (the application has to make sure that 453 * make sure that this happens if required).
453 * this happens if required).
454 */ 454 */
455 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, 455 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE,
456 456
@@ -460,18 +460,16 @@ enum GNUNET_CONTAINER_MultiHashMapOption
460 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, 460 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE,
461 461
462 /** 462 /**
463 * There must only be one value per key; storing 463 * There must only be one value per key; storing a value should fail
464 * a value should fail if a value under the same 464 * if a value under the same key already exists.
465 * key already exists.
466 */ 465 */
467 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, 466 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY,
468 467
469 /** 468 /**
470 * There must only be one value per key, but don't 469 * There must only be one value per key, but don't bother checking
471 * bother checking if a value already exists 470 * if a value already exists (faster than UNIQUE_ONLY; implemented
472 * (faster than UNIQUE_ONLY; implemented just like 471 * just like MULTIPLE but this option documents better what is
473 * MULTIPLE but this option documents better what 472 * intended if UNIQUE is what is desired).
474 * is intended if UNIQUE is what is desired).
475 */ 473 */
476 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST 474 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
477}; 475};
@@ -501,6 +499,7 @@ typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls,
501struct GNUNET_CONTAINER_MultiHashMap 499struct GNUNET_CONTAINER_MultiHashMap
502 *GNUNET_CONTAINER_multihashmap_create (unsigned int len); 500 *GNUNET_CONTAINER_multihashmap_create (unsigned int len);
503 501
502
504/** 503/**
505 * Destroy a hash map. Will not free any values 504 * Destroy a hash map. Will not free any values
506 * stored in the hash map! 505 * stored in the hash map!
@@ -511,9 +510,9 @@ void GNUNET_CONTAINER_multihashmap_destroy (struct
511 GNUNET_CONTAINER_MultiHashMap 510 GNUNET_CONTAINER_MultiHashMap
512 *map); 511 *map);
513 512
513
514/** 514/**
515 * Given a key find a value in the 515 * Given a key find a value in the map matching the key.
516 * map matching the key.
517 * 516 *
518 * @param map the map 517 * @param map the map
519 * @param key what to look for 518 * @param key what to look for
@@ -526,11 +525,11 @@ void *GNUNET_CONTAINER_multihashmap_get (const struct
526 GNUNET_CONTAINER_MultiHashMap *map, 525 GNUNET_CONTAINER_MultiHashMap *map,
527 const GNUNET_HashCode * key); 526 const GNUNET_HashCode * key);
528 527
528
529/** 529/**
530 * Remove the given key-value pair from the map. 530 * Remove the given key-value pair from the map. Note that if the
531 * Note that if the key-value pair is in the map 531 * key-value pair is in the map multiple times, only one of the pairs
532 * multiple times, only one of the pairs will be 532 * will be removed.
533 * removed.
534 * 533 *
535 * @param map the map 534 * @param map the map
536 * @param key key of the key-value pair 535 * @param key key of the key-value pair
@@ -555,6 +554,7 @@ int GNUNET_CONTAINER_multihashmap_remove_all (struct
555 *map, 554 *map,
556 const GNUNET_HashCode * key); 555 const GNUNET_HashCode * key);
557 556
557
558/** 558/**
559 * Check if the map contains any value under the given 559 * Check if the map contains any value under the given
560 * key (including values that are NULL). 560 * key (including values that are NULL).
@@ -569,6 +569,7 @@ int GNUNET_CONTAINER_multihashmap_contains (const struct
569 *map, 569 *map,
570 const GNUNET_HashCode * key); 570 const GNUNET_HashCode * key);
571 571
572
572/** 573/**
573 * Store a key-value pair in the map. 574 * Store a key-value pair in the map.
574 * 575 *
@@ -603,24 +604,24 @@ unsigned int GNUNET_CONTAINER_multihashmap_size (const struct
603 * Iterate over all entries in the map. 604 * Iterate over all entries in the map.
604 * 605 *
605 * @param map the map 606 * @param map the map
606 * @param iterator function to call on each entry 607 * @param it function to call on each entry
607 * @param cls extra argument to it 608 * @param it_cls extra argument to it
608 * @return the number of key value pairs processed, 609 * @return the number of key value pairs processed,
609 * GNUNET_SYSERR if it aborted iteration 610 * GNUNET_SYSERR if it aborted iteration
610 */ 611 */
611int GNUNET_CONTAINER_multihashmap_iterate (const struct 612int GNUNET_CONTAINER_multihashmap_iterate (const struct
612 GNUNET_CONTAINER_MultiHashMap *map, 613 GNUNET_CONTAINER_MultiHashMap *map,
613 GNUNET_CONTAINER_HashMapIterator 614 GNUNET_CONTAINER_HashMapIterator
614 iterator, void *cls); 615 it, void *it_cls);
616
615 617
616/** 618/**
617 * Iterate over all entries in the map 619 * Iterate over all entries in the map that match a particular key.
618 * that match a particular key.
619 * 620 *
620 * @param map the map 621 * @param map the map
621 * @param key key that the entries must correspond to 622 * @param key key that the entries must correspond to
622 * @param iterator function to call on each entry 623 * @param it function to call on each entry
623 * @param cls extra argument to it 624 * @param it_cls extra argument to it
624 * @return the number of key value pairs processed, 625 * @return the number of key value pairs processed,
625 * GNUNET_SYSERR if it aborted iteration 626 * GNUNET_SYSERR if it aborted iteration
626 */ 627 */
@@ -629,13 +630,17 @@ int GNUNET_CONTAINER_multihashmap_get_multiple (const struct
629 *map, 630 *map,
630 const GNUNET_HashCode * key, 631 const GNUNET_HashCode * key,
631 GNUNET_CONTAINER_HashMapIterator 632 GNUNET_CONTAINER_HashMapIterator
632 iterator, void *cls); 633 it, void *it_cls);
634
635
633/** 636/**
634 * Returns the stored value of a random non-null entry 637 * Returns the stored value of a random non-null entry in the hash
635 * in the hash table. Returns only the first value, does 638 * table. Returns only the first value, does not go inside bucket
636 * not go inside bucket linked list (yet). Runs with a 639 * linked list (yet). Runs with a worst case time of N, so it's not
637 * worst case time of N, so it's not efficient in any way 640 * efficient in any way shape or form!!!!.
638 * shape or form!!!!. 641 *
642 * @param map the map
643 * @return value associated with a random key
639 */ 644 */
640void *GNUNET_CONTAINER_multihashmap_get_random (const struct 645void *GNUNET_CONTAINER_multihashmap_get_random (const struct
641 GNUNET_CONTAINER_MultiHashMap 646 GNUNET_CONTAINER_MultiHashMap