2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_container_lib.h
23 * @brief container classes for GNUnet
25 * @author Christian Grothoff
29 #ifndef GNUNET_CONTAINER_LIB_H
30 #define GNUNET_CONTAINER_LIB_H
32 /* add error and config prototypes */
33 #include "gnunet_crypto_lib.h"
34 #include <extractor.h>
39 #if 0 /* keep Emacsens' auto-indent happy */
45 /* ******************* bloomfilter ***************** */
48 * @brief bloomfilter representation (opaque)
50 struct GNUNET_CONTAINER_BloomFilter;
53 * Iterator over HashCodes.
56 * @param next set to the next hash code
57 * @return GNUNET_YES if next was updated
58 * GNUNET_NO if there are no more entries
60 typedef int (*GNUNET_HashCodeIterator) (void *cls,
61 GNUNET_HashCode * next);
64 * Load a bloom-filter from a file.
65 * @param filename the name of the file (or the prefix)
66 * @param size the size of the bloom-filter (number of
67 * bytes of storage space to use)
68 * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
69 * element (number of bits set per element in the set)
70 * @return the bloomfilter
72 struct GNUNET_CONTAINER_BloomFilter *GNUNET_CONTAINER_bloomfilter_load (const
83 * Create a bloom filter from raw bits.
85 * @param data the raw bits in memory (maybe NULL,
86 * in which case all bits should be considered
88 * @param size the size of the bloom-filter (number of
89 * bytes of storage space to use); also size of data
90 * -- unless data is NULL. Must be a power of 2.
91 * @param k the number of GNUNET_CRYPTO_hash-functions to apply per
92 * element (number of bits set per element in the set)
93 * @return the bloomfilter
95 struct GNUNET_CONTAINER_BloomFilter *GNUNET_CONTAINER_bloomfilter_init (const
106 * Copy the raw data of this bloomfilter into
107 * the given data array.
109 * @param data where to write the data
110 * @param size the size of the given data array
111 * @return GNUNET_SYSERR if the data array of the wrong size
113 int GNUNET_CONTAINER_bloomfilter_get_raw_data (struct
114 GNUNET_CONTAINER_BloomFilter
119 * Test if an element is in the filter.
120 * @param e the element
121 * @param bf the filter
122 * @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
124 int GNUNET_CONTAINER_bloomfilter_test (struct GNUNET_CONTAINER_BloomFilter
125 *bf, const GNUNET_HashCode * e);
128 * Add an element to the filter
129 * @param bf the filter
130 * @param e the element
132 void GNUNET_CONTAINER_bloomfilter_add (struct GNUNET_CONTAINER_BloomFilter
133 *bf, const GNUNET_HashCode * e);
136 * Remove an element from the filter.
137 * @param bf the filter
138 * @param e the element to remove
140 void GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter
141 *bf, const GNUNET_HashCode * e);
144 * Free the space associcated with a filter
145 * in memory, flush to drive if needed (do not
146 * free the space on the drive)
147 * @param bf the filter
149 void GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter
153 * Reset a bloom filter to empty.
154 * @param bf the filter
156 void GNUNET_CONTAINER_bloomfilter_clear (struct GNUNET_CONTAINER_BloomFilter
160 * Or the entries of the given raw data array with the
161 * data of the given bloom filter. Assumes that
162 * the size of the data array and the current filter
164 * @param bf the filter
166 int GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
167 const char *data, unsigned int size);
170 * Resize a bloom filter. Note that this operation
171 * is pretty costly. Essentially, the bloom filter
172 * needs to be completely re-build.
174 * @param bf the filter
175 * @param iterator an iterator over all elements stored in the BF
176 * @param iterator_cls closure for iterator
177 * @param size the new size for the filter
178 * @param k the new number of GNUNET_CRYPTO_hash-function to apply per element
180 void GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter
182 GNUNET_HashCodeIterator iterator,
184 unsigned int size, unsigned int k);
186 /* ****************** metadata ******************* */
189 * Meta data to associate with a file, directory or namespace.
191 struct GNUNET_CONTAINER_MetaData;
194 * Iterator over meta data.
197 * @param type type of the meta data
198 * @param data value of the meta data
199 * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
201 typedef int (*GNUNET_CONTAINER_MetaDataProcessor) (void *cls,
202 EXTRACTOR_KeywordType type,
206 * Create a fresh MetaData token.
208 * @return empty meta-data container
210 struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void);
213 * Duplicate a MetaData token.
215 * @param meta what to duplicate
216 * @return duplicate meta-data container
218 struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const
220 GNUNET_CONTAINER_MetaData
226 * @param md what to free
228 void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData
232 * Test if two MDs are equal.
234 * @param md1 first value to check
235 * @param md2 other value to check
236 * @return GNUNET_YES if they are equal
238 int GNUNET_CONTAINER_meta_data_test_equal (const struct
239 GNUNET_CONTAINER_MetaData *md1,
241 GNUNET_CONTAINER_MetaData *md2);
247 * @param md metadata to extend
248 * @param type type of the new entry
249 * @param data value for the entry
250 * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists
252 int GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md,
253 EXTRACTOR_KeywordType type,
259 * @param type type of the item to remove
260 * @param data specific value to remove, NULL to remove all
261 * entries of the given type
262 * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md
264 int GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md,
265 EXTRACTOR_KeywordType type,
269 * Add the current time as the publication date
272 * @param md metadata to modify
274 void GNUNET_CONTAINER_meta_data_add_publication_date (struct
275 GNUNET_CONTAINER_MetaData
279 * Iterate over MD entries, excluding thumbnails.
281 * @param md metadata to inspect
282 * @param iter function to call on each entry
283 * @param iter_cls closure for iterator
284 * @return number of entries
286 int GNUNET_CONTAINER_meta_data_get_contents (const struct
287 GNUNET_CONTAINER_MetaData *md,
288 GNUNET_CONTAINER_MetaDataProcessor
289 iter, void *iter_cls);
292 * Get the first MD entry of the given type.
294 * @param md metadata to inspect
295 * @param type type to look for
296 * @return NULL if we do not have any such entry,
297 * otherwise client is responsible for freeing the value!
299 char *GNUNET_CONTAINER_meta_data_get_by_type (const struct
300 GNUNET_CONTAINER_MetaData *md,
301 EXTRACTOR_KeywordType type);
304 * Get the first matching MD entry of the given types.
306 * @param md metadata to inspect
307 * @param ... -1-terminated list of types
308 * @return NULL if we do not have any such entry,
309 * otherwise client is responsible for freeing the value!
311 char *GNUNET_CONTAINER_meta_data_get_first_by_types (const struct
312 GNUNET_CONTAINER_MetaData
316 * Get a thumbnail from the meta-data (if present).
318 * @param md metadata to inspect
319 * @param thumb will be set to the thumbnail data. Must be
320 * freed by the caller!
321 * @return number of bytes in thumbnail, 0 if not available
323 size_t GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
324 GNUNET_CONTAINER_MetaData
325 *md, unsigned char **thumb);
328 * Extract meta-data from a file.
330 * @param md metadata to set
331 * @param filename name of file to inspect
332 * @param extractors plugins to use
333 * @return GNUNET_SYSERR on error, otherwise the number
334 * of meta-data items obtained
336 int GNUNET_CONTAINER_meta_data_extract_from_file (struct
337 GNUNET_CONTAINER_MetaData
338 *md, const char *filename,
339 EXTRACTOR_ExtractorList *
342 enum GNUNET_CONTAINER_MetaDataSerializationOptions
344 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL = 0,
345 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART = 1,
346 GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS = 2
352 * Serialize meta-data to target.
354 * @param md metadata to serialize
355 * @param size maximum number of bytes available
356 * @param opt is it ok to just write SOME of the
357 * meta-data to match the size constraint,
358 * possibly discarding some data?
359 * @return number of bytes written on success,
360 * -1 on error (typically: not enough
363 ssize_t GNUNET_CONTAINER_meta_data_serialize (const struct
364 GNUNET_CONTAINER_MetaData *md,
368 GNUNET_CONTAINER_MetaDataSerializationOptions
372 * Compute size of the meta-data in
375 * @param md metadata to inspect
376 * @param opt is it ok to just write SOME of the
377 * meta-data to match the size constraint,
378 * possibly discarding some data?
379 * @return number of bytes needed for serialization, -1 on error
381 ssize_t GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
382 GNUNET_CONTAINER_MetaData
385 GNUNET_CONTAINER_MetaDataSerializationOptions
389 * Deserialize meta-data. Initializes md.
391 * @param input serialized meta-data.
392 * @param size number of bytes available
393 * @return MD on success, NULL on error (i.e.
396 struct GNUNET_CONTAINER_MetaData
397 *GNUNET_CONTAINER_meta_data_deserialize (const char *input,
401 * Does the meta-data claim that this is a directory?
402 * Checks if the mime-type is that of a GNUnet directory.
404 * @param md metadata to inspect
405 * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
406 * we have no mime-type information (treat as 'GNUNET_NO')
408 int GNUNET_CONTAINER_meta_data_test_for_directory (const struct
409 GNUNET_CONTAINER_MetaData
413 /* ******************************* HashMap **************************** */
416 * Opaque handle for a HashMap.
418 struct GNUNET_CONTAINER_MultiHashMap;
421 * Options for storing values in the HashMap.
423 enum GNUNET_CONTAINER_MultiHashMapOption
426 * If a value with the given key exists, replace it.
427 * Note that the old value would NOT be freed
428 * by replace (the application has to make sure that
429 * this happens if required).
431 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE,
434 * Allow multiple values with the same key.
436 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE,
439 * There must only be one value per key; storing
440 * a value should fail if a value under the same
441 * key already exists.
443 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY,
446 * There must only be one value per key, but don't
447 * bother checking if a value already exists
448 * (faster than UNIQUE_ONLY; implemented just like
449 * MULTIPLE but this option documents better what
450 * is intended if UNIQUE is what is desired).
452 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
456 * Iterator over HashCodes.
458 * @param key current key code
459 * @param value value in the hash map
460 * @param cls client-defined argument
461 * @return GNUNET_YES if we should continue to
465 typedef int (*GNUNET_CONTAINER_HashMapIterator) (const GNUNET_HashCode * key,
466 void *value, void *cls);
470 * Create a multi hash map.
473 * @param len initial size (map will grow as needed)
474 * @return NULL on error
476 struct GNUNET_CONTAINER_MultiHashMap
477 *GNUNET_CONTAINER_multihashmap_create (unsigned int len);
480 * Destroy a hash map. Will not free any values
481 * stored in the hash map!
485 void GNUNET_CONTAINER_multihashmap_destroy (struct
486 GNUNET_CONTAINER_MultiHashMap
490 * Given a key find a value in the
491 * map matching the key.
494 * @param key what to look for
495 * @return NULL if no value was found; note that
496 * this is indistinguishable from values that just
497 * happen to be NULL; use "contains" to test for
498 * key-value pairs with value NULL
500 void *GNUNET_CONTAINER_multihashmap_get (const struct
501 GNUNET_CONTAINER_MultiHashMap *map,
502 const GNUNET_HashCode * key);
505 * Remove the given key-value pair from the map.
506 * Note that if the key-value pair is in the map
507 * multiple times, only one of the pairs will be
511 * @param key key of the key-value pair
512 * @param value value of the key-value pair
513 * @return GNUNET_YES on success, GNUNET_NO if the key-value pair
516 int GNUNET_CONTAINER_multihashmap_remove (struct GNUNET_CONTAINER_MultiHashMap
517 *map, const GNUNET_HashCode * key,
521 * Remove all entries for the given key from the map.
522 * Note that the values would not be "freed".
525 * @param key identifies values to be removed
526 * @return number of values removed
528 int GNUNET_CONTAINER_multihashmap_remove_all (struct
529 GNUNET_CONTAINER_MultiHashMap
531 const GNUNET_HashCode * key);
534 * Check if the map contains any value under the given
535 * key (including values that are NULL).
538 * @param key the key to test if a value exists for it
539 * @return GNUNET_YES if such a value exists,
542 int GNUNET_CONTAINER_multihashmap_contains (const struct
543 GNUNET_CONTAINER_MultiHashMap
545 const GNUNET_HashCode * key);
548 * Store a key-value pair in the map.
551 * @param key key to use
552 * @param value value to use
553 * @param opt options for put
554 * @return GNUNET_OK on success,
555 * GNUNET_NO if a value was replaced (with REPLACE)
556 * GNUNET_SYSERR if UNIQUE_ONLY was the option and the
557 * value already exists
559 int GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap
560 *map, const GNUNET_HashCode * key,
563 GNUNET_CONTAINER_MultiHashMapOption
567 * Get the number of key-value pairs in the map.
570 * @return the number of key value pairs
572 unsigned int GNUNET_CONTAINER_multihashmap_size (const struct
573 GNUNET_CONTAINER_MultiHashMap
578 * Iterate over all entries in the map.
581 * @param iterator function to call on each entry
582 * @param cls extra argument to it
583 * @return the number of key value pairs processed,
584 * GNUNET_SYSERR if it aborted iteration
586 int GNUNET_CONTAINER_multihashmap_iterate (const struct
587 GNUNET_CONTAINER_MultiHashMap *map,
588 GNUNET_CONTAINER_HashMapIterator
589 iterator, void *cls);
592 * Iterate over all entries in the map
593 * that match a particular key.
596 * @param key key that the entries must correspond to
597 * @param iterator function to call on each entry
598 * @param cls extra argument to it
599 * @return the number of key value pairs processed,
600 * GNUNET_SYSERR if it aborted iteration
602 int GNUNET_CONTAINER_multihashmap_get_multiple (const struct
603 GNUNET_CONTAINER_MultiHashMap
605 const GNUNET_HashCode * key,
606 GNUNET_CONTAINER_HashMapIterator
607 iterator, void *cls);
609 * Returns the stored value of a random non-null entry
610 * in the hash table. Returns only the first value, does
611 * not go inside bucket linked list (yet). Runs with a
612 * worst case time of N, so it's not efficient in any way
615 void *GNUNET_CONTAINER_multihashmap_get_random (const struct
616 GNUNET_CONTAINER_MultiHashMap
622 /* ******************** doubly-linked list *************** */
625 * Insert an element into a DLL. Assumes
626 * that head, tail and element are structs
627 * with prev and next fields.
629 #define GNUNET_CONTAINER_DLL_insert(head,tail,element) \
630 (element)->next = (head); \
631 (element)->prev = NULL; \
632 if ((tail) == NULL) \
635 (head)->prev = element; \
639 * Insert an element into a DLL after the given other
640 * element. Insert at the head if the other
643 #define GNUNET_CONTAINER_DLL_insert_after(head,tail,other,element) \
644 (element)->prev = (other); \
647 (element)->next = (head); \
648 (head) = (element); \
652 (element)->next = (other)->next; \
653 (other)->next = (element); \
655 if (NULL == (element)->next) \
656 (tail) = (element); \
658 (element)->next->prev = (element);
664 * Remove an element from a DLL. Assumes
665 * that head, tail and element are structs
666 * with prev and next fields.
668 #define GNUNET_CONTAINER_DLL_remove(head,tail,element) \
669 if ((element)->prev == NULL) \
670 (head) = (element)->next; \
672 (element)->prev->next = (element)->next; \
673 if ((element)->next == NULL) \
674 (tail) = (element)->prev; \
676 (element)->next->prev = (element)->prev;
680 /* ******************** Heap *************** */
684 * Cost by which elements in a heap can be ordered.
686 typedef unsigned int GNUNET_CONTAINER_HeapCost;
689 * Heap type, either max or min. Hopefully makes the
690 * implementation more useful.
692 enum GNUNET_CONTAINER_HeapOrder
695 * Heap with the maximum cost at the root.
697 GNUNET_CONTAINER_HEAP_ORDER_MAX,
700 * Heap with the minimum cost at the root.
702 GNUNET_CONTAINER_HEAP_ORDER_MIN
708 struct GNUNET_CONTAINER_Heap;
713 * @param type should the minimum or the maximum element be the root
714 * @return NULL on error, otherwise a fresh heap
716 struct GNUNET_CONTAINER_Heap *GNUNET_CONTAINER_heap_create (enum
717 GNUNET_CONTAINER_HeapOrder
723 * @param h heap to free.
725 void GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *h);
728 * Function called on elements of a heap.
731 * @param element obj stored in heap
732 * @param cost cost of the element
733 * @return GNUNET_YES if we should continue to iterate,
736 typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls,
738 GNUNET_CONTAINER_HeapCost cost);
740 * Iterate over all entries in the map.
742 * @param heap the heap
743 * @param iterator function to call on each entry
744 * @param iterator_cls closure for iterator
745 * @return number of items handled
746 * GNUNET_SYSERR if iteration was aborted by iterator
748 int GNUNET_CONTAINER_heap_iterate (struct GNUNET_CONTAINER_Heap *heap,
749 GNUNET_CONTAINER_HeapIterator iterator,
754 * Inserts a new item into the heap, item is always neighbor now.
755 * @param heap the heap
758 GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap,
759 void *element, GNUNET_CONTAINER_HeapCost cost);
762 * Removes root of the tree, is remove max if a max heap and remove min
763 * if a min heap, returns the data stored at the node.
765 * @param heap the heap
766 * @return NULL if the heap is empty
768 void *GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap);
771 * Returns element stored at root of tree, doesn't effect anything
773 * @param heap the heap
774 * @return NULL if the heap is empty
776 void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *heap);
779 * Removes any node from the tree based on the neighbor given, does
780 * not traverse the tree (backpointers) but may take more time due to
781 * percolation of nodes.
782 * @param heap the heap
784 void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *heap,
788 * Updates the cost of any node in the tree
790 * @param heap the heap
791 * @param element the element for which the cost is updated
792 * @param new_cost new cost for the element
796 GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
798 GNUNET_CONTAINER_HeapCost new_cost);
801 * Random walk of the tree, returns the data stored at the next random node
802 * in the walk. Calls callee with the data, or NULL if the tree is empty
803 * or some other problem crops up.
805 * @param heap the heap
806 * @return the next element from the random walk
808 void *GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap
812 * Returns the current size of the heap
814 * @param heap the heap to get the size of
815 * @return number of elements in the heap
818 GNUNET_CONTAINER_heap_get_size (struct GNUNET_CONTAINER_Heap *heap);
821 /* ******************** Vector *************** */
826 struct GNUNET_CONTAINER_Vector;
829 * A debug function that traverses the linked list and prints the
830 * sizes of the segments.
832 void GNUNET_CONTAINER_vector_dump(struct GNUNET_CONTAINER_Vector *v);
835 * Allocate a new vector structure with a single empty data segment.
837 struct GNUNET_CONTAINER_Vector * GNUNET_CONTAINER_vector_create(unsigned int vss);
840 * Free vector structure including its data segments, but _not_ including the
841 * stored void pointers. It is the user's responsibility to empty the vector
842 * when necessary to avoid memory leakage.
844 void GNUNET_CONTAINER_vector_destroy(struct GNUNET_CONTAINER_Vector *v);
847 * Return the size of the vector.
849 size_t GNUNET_CONTAINER_vector_size(struct GNUNET_CONTAINER_Vector *v);
852 * Insert a new element in the vector at given index. The return value is
853 * OK on success, SYSERR if the index is out of bounds.
855 int GNUNET_CONTAINER_vector_insert_at(struct GNUNET_CONTAINER_Vector *v,
860 * Insert a new element at the end of the vector.
862 void GNUNET_CONTAINER_vector_insert_last(struct GNUNET_CONTAINER_Vector *v, void *object);
865 * Return the element at given index in the vector or NULL if the index is out
866 * of bounds. The iterator is set to point to the returned element.
868 void * GNUNET_CONTAINER_vector_get_at(struct GNUNET_CONTAINER_Vector *v,
872 * Return the first element in the vector, whose index is 0, or NULL if the
873 * vector is empty. The iterator of the vector is set to point to the first
876 void * GNUNET_CONTAINER_vector_get_first(struct GNUNET_CONTAINER_Vector *v);
879 * Return the last element in the vector or NULL if the vector is
880 * empty. The iterator of the vector is set to the last element.
882 void * GNUNET_CONTAINER_vector_get_last(struct GNUNET_CONTAINER_Vector *v);
885 * Return the next element in the vector, as called after vector_get_at() or
886 * vector_get_first(). The return value is NULL if there are no more elements
887 * in the vector or if the iterator has not been set.
889 void * GNUNET_CONTAINER_vector_get_next(struct GNUNET_CONTAINER_Vector *v);
892 * Return the previous element in the vector, as called after vector_get_at()
893 * or vector_get_last(). The return value is NULL if there are no more
894 * elements in the vector or if the iterator has not been set.
896 void * GNUNET_CONTAINER_vector_get_previous(struct GNUNET_CONTAINER_Vector * v);
899 * Delete and return the element at given index. NULL is returned if index is
902 void * GNUNET_CONTAINER_vector_remove_at(struct GNUNET_CONTAINER_Vector *v,
906 * Delete and return the last element in the vector, or NULL if the vector
909 void *GNUNET_CONTAINER_vector_remove_last (struct GNUNET_CONTAINER_Vector *v);
912 * Delete and return given object from the vector, or return NULL if the object
915 void * GNUNET_CONTAINER_vector_remove_object(struct GNUNET_CONTAINER_Vector *v, void *object);
918 * Set the given index in the vector. The old value of the index is
919 * returned, or NULL if the index is out of bounds.
921 void *GNUNET_CONTAINER_vector_set_at (struct GNUNET_CONTAINER_Vector *v,
926 * Set the index occupied by the given object to point to the new object.
927 * The old object is returned, or NULL if it's not found.
929 void *GNUNET_CONTAINER_vector_set_object(struct GNUNET_CONTAINER_Vector *v,
934 * Swaps the contents of index1 and index2. Return value is OK
935 * on success, SYSERR if either index is out of bounds.
937 int GNUNET_CONTAINER_vector_swap(struct GNUNET_CONTAINER_Vector *v,
939 unsigned int index2);
942 * Return the index of given element or -1 if the element is not found.
944 unsigned int GNUNET_CONTAINER_vector_index_of(struct GNUNET_CONTAINER_Vector *v,
948 * Return the data stored in the vector as a single dynamically allocated
949 * array of (void *), which must be free(3)d by the user. Use the functions
950 * get_{at,first,last,next,previous} instead, unless you really need to access
951 * everything in the vector as fast as possible.
953 void ** GNUNET_CONTAINER_vector_elements (struct GNUNET_CONTAINER_Vector *v);
956 #if 0 /* keep Emacsens' auto-indent happy */
964 /* ifndef GNUNET_CONTAINER_LIB_H */
966 /* end of gnunet_container_lib.h */