aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-04-17 09:41:59 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-04-17 09:41:59 +0000
commit7e53c7855a15eb7049d391f1a1b32aff822c5c5b (patch)
treeed7e3decb1f79a7721675f4b532e8a684bf104a8 /src/include
parent0555e4e107db9c0c1f0caa6c947881c32bf426f4 (diff)
downloadgnunet-7e53c7855a15eb7049d391f1a1b32aff822c5c5b.tar.gz
gnunet-7e53c7855a15eb7049d391f1a1b32aff822c5c5b.zip
- 32-bit key hashmap
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_container_lib.h190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index 1c75d7bc5..d52591148 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -706,6 +706,196 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct
706 GNUNET_CONTAINER_HashMapIterator it, 706 GNUNET_CONTAINER_HashMapIterator it,
707 void *it_cls); 707 void *it_cls);
708 708
709/* Version of multihashmap with 32 bit keys */
710
711/**
712 * Opaque handle for the 32-bit key HashMap.
713 */
714struct GNUNET_CONTAINER_MultiHashMap32;
715
716
717/**
718 * Iterator over hash map entries.
719 *
720 * @param cls closure
721 * @param key current key code
722 * @param value value in the hash map
723 * @return GNUNET_YES if we should continue to
724 * iterate,
725 * GNUNET_NO if not.
726 */
727typedef int (*GNUNET_CONTAINER_HashMapIterator32) (void *cls,
728 uint32_t key,
729 void *value);
730
731
732/**
733 * Create a 32-bit key multi hash map.
734 *
735 * @param len initial size (map will grow as needed)
736 * @return NULL on error
737 */
738struct GNUNET_CONTAINER_MultiHashMap32 *
739GNUNET_CONTAINER_multihashmap32_create (unsigned int len);
740
741
742/**
743 * Destroy a 32-bit key hash map. Will not free any values
744 * stored in the hash map!
745 *
746 * @param map the map
747 */
748void
749GNUNET_CONTAINER_multihashmap32_destroy (struct GNUNET_CONTAINER_MultiHashMap32
750 *map);
751
752
753/**
754 * Get the number of key-value pairs in the map.
755 *
756 * @param map the map
757 * @return the number of key value pairs
758 */
759unsigned int
760GNUNET_CONTAINER_multihashmap32_size (const struct
761 GNUNET_CONTAINER_MultiHashMap32 *map);
762
763
764/**
765 * Given a key find a value in the map matching the key.
766 *
767 * @param map the map
768 * @param key what to look for
769 * @return NULL if no value was found; note that
770 * this is indistinguishable from values that just
771 * happen to be NULL; use "contains" to test for
772 * key-value pairs with value NULL
773 */
774void *
775GNUNET_CONTAINER_multihashmap32_get (const struct
776 GNUNET_CONTAINER_MultiHashMap32 *map,
777 uint32_t key);
778
779
780/**
781 * Iterate over all entries in the map.
782 *
783 * @param map the map
784 * @param it function to call on each entry
785 * @param it_cls extra argument to it
786 * @return the number of key value pairs processed,
787 * GNUNET_SYSERR if it aborted iteration
788 */
789int
790GNUNET_CONTAINER_multihashmap32_iterate (const struct
791 GNUNET_CONTAINER_MultiHashMap32 *map,
792 GNUNET_CONTAINER_HashMapIterator32 it,
793 void *it_cls);
794
795
796/**
797 * Remove the given key-value pair from the map. Note that if the
798 * key-value pair is in the map multiple times, only one of the pairs
799 * will be removed.
800 *
801 * @param map the map
802 * @param key key of the key-value pair
803 * @param value value of the key-value pair
804 * @return GNUNET_YES on success, GNUNET_NO if the key-value pair
805 * is not in the map
806 */
807int
808GNUNET_CONTAINER_multihashmap32_remove (struct GNUNET_CONTAINER_MultiHashMap32
809 *map,
810 uint32_t key, void *value);
811
812
813/**
814 * Remove all entries for the given key from the map.
815 * Note that the values would not be "freed".
816 *
817 * @param map the map
818 * @param key identifies values to be removed
819 * @return number of values removed
820 */
821int
822GNUNET_CONTAINER_multihashmap32_remove_all (struct
823 GNUNET_CONTAINER_MultiHashMap32
824 *map,
825 uint32_t key);
826
827
828/**
829 * Check if the map contains any value under the given
830 * key (including values that are NULL).
831 *
832 * @param map the map
833 * @param key the key to test if a value exists for it
834 * @return GNUNET_YES if such a value exists,
835 * GNUNET_NO if not
836 */
837int
838GNUNET_CONTAINER_multihashmap32_contains (const struct
839 GNUNET_CONTAINER_MultiHashMap32 *map,
840 uint32_t key);
841
842
843/**
844 * Check if the map contains the given value under the given
845 * key.
846 *
847 * @param map the map
848 * @param key the key to test if a value exists for it
849 * @param value value to test for
850 * @return GNUNET_YES if such a value exists,
851 * GNUNET_NO if not
852 */
853int
854GNUNET_CONTAINER_multihashmap32_contains_value (const struct
855 GNUNET_CONTAINER_MultiHashMap32
856 *map,
857 uint32_t key,
858 const void *value);
859
860
861/**
862 * Store a key-value pair in the map.
863 *
864 * @param map the map
865 * @param key key to use
866 * @param value value to use
867 * @param opt options for put
868 * @return GNUNET_OK on success,
869 * GNUNET_NO if a value was replaced (with REPLACE)
870 * GNUNET_SYSERR if UNIQUE_ONLY was the option and the
871 * value already exists
872 */
873int
874GNUNET_CONTAINER_multihashmap32_put (struct GNUNET_CONTAINER_MultiHashMap32
875 *map, uint32_t key, void *value,
876 enum GNUNET_CONTAINER_MultiHashMapOption
877 opt);
878
879
880/**
881 * Iterate over all entries in the map that match a particular key.
882 *
883 * @param map the map
884 * @param key key that the entries must correspond to
885 * @param it function to call on each entry
886 * @param it_cls extra argument to it
887 * @return the number of key value pairs processed,
888 * GNUNET_SYSERR if it aborted iteration
889 */
890int
891GNUNET_CONTAINER_multihashmap32_get_multiple (const struct
892 GNUNET_CONTAINER_MultiHashMap32
893 *map, uint32_t key,
894 GNUNET_CONTAINER_HashMapIterator32
895 it, void *it_cls);
896
897
898
709 899
710/* ******************** doubly-linked list *************** */ 900/* ******************** doubly-linked list *************** */
711/* To avoid mistakes: head->prev == tail->next == NULL */ 901/* To avoid mistakes: head->prev == tail->next == NULL */