ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dictionary.h
Go to the documentation of this file.
00001 /* Simple dictionary
00002  *
00003  * Copyright 2005 Juan Lang
00004  *
00005  * This is a pretty basic dictionary, or map if you prefer.  It's not
00006  * thread-safe.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00021  */
00022 #ifndef __DICTIONARY_H__
00023 #define __DICTIONARY_H__
00024 
00025 #include <stdarg.h>
00026 #include "windef.h"
00027 #include "winbase.h"
00028 
00029 struct dictionary;
00030 
00031 /* Returns whether key a is less than, equal to, or greater than key b, in
00032  * the same way (a - b) would for integers or strcmp(a, b) would for ANSI
00033  * strings.
00034  */
00035 typedef int (*comparefunc)(const void *a, const void *b, void *extra);
00036 
00037 /* Called for every element removed from the dictionary.  See
00038  * dictionary_destroy, dictionary_insert, and dictionary_remove.
00039  */
00040 typedef void (*destroyfunc)(void *k, void *v, void *extra);
00041 
00042 /* Called for each element in the dictionary.  Return FALSE if you don't want
00043  * to enumerate any more.
00044  */
00045 typedef BOOL (*enumeratefunc)(const void *k, const void *v, void *extra,
00046  void *closure);
00047 
00048 /* Constructs a dictionary, using c as a comparison function for keys.
00049  * If d is not NULL, it will be called whenever an item is about to be removed
00050  * from the table, for example when dictionary_remove is called for a key, or
00051  * when dictionary_destroy is called.
00052  * extra is passed to c (and d, if it's provided).
00053  * Assumes c is not NULL.
00054  */
00055 struct dictionary *dictionary_create(comparefunc c, destroyfunc d, void *extra) DECLSPEC_HIDDEN;
00056 
00057 /* Assumes d is not NULL. */
00058 void dictionary_destroy(struct dictionary *d) DECLSPEC_HIDDEN;
00059 
00060 /* Returns how many entries have been stored in the dictionary.  If two values
00061  * with the same key are inserted, only one is counted.
00062  */
00063 UINT dictionary_num_entries(struct dictionary *d) DECLSPEC_HIDDEN;
00064 
00065 /* Sets an element with key k and value v to the dictionary.  If a value
00066  * already exists with key k, its value is replaced, and the destroyfunc (if
00067  * set) is called for the previous item.
00068  * Assumes k and v can be bitwise-copied.
00069  * Both k and v are allowed to be NULL, in case you want to use integer
00070  * values for either the key or the value.
00071  * Assumes d is not NULL.
00072  */
00073 void dictionary_insert(struct dictionary *d, const void *k, const void *v) DECLSPEC_HIDDEN;
00074 
00075 /* If a value with key k has been inserted into the dictionary, *v is set
00076  * to its associated value.  Returns FALSE if the key is not found, and TRUE
00077  * if it is.  *v is undefined if it returns FALSE.  (It is not set to NULL,
00078  * because this dictionary doesn't prevent you from using NULL as a value
00079  * value; see dictionary_insert.)
00080  * Assumes d and v are not NULL.
00081  */
00082 BOOL dictionary_find(struct dictionary *d, const void *k, void **v) DECLSPEC_HIDDEN;
00083 
00084 /* Removes the element with key k from the dictionary.  Calls the destroyfunc
00085  * for the dictionary with the element if found (so you may destroy it if it's
00086  * dynamically allocated.)
00087  * Assumes d is not NULL.
00088  */
00089 void dictionary_remove(struct dictionary *d, const void *k) DECLSPEC_HIDDEN;
00090 
00091 void dictionary_enumerate(struct dictionary *d, enumeratefunc e, void *closure) DECLSPEC_HIDDEN;
00092 
00093 #endif /* ndef __DICTIONARY_H__ */

Generated on Sat May 26 2012 04:24:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.