]>
Commit | Line | Data |
---|---|---|
9dbf2019 TB |
1 | /* |
2 | * Copyright (C) 2014 Tobias Brunner | |
19ef2aec TB |
3 | * |
4 | * Copyright (C) secunet Security Networks AG | |
9dbf2019 TB |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | * for more details. | |
15 | */ | |
16 | ||
17 | /** | |
18 | * @defgroup dictionary dictionary | |
19 | * @{ @ingroup collections | |
20 | */ | |
21 | ||
22 | #ifndef DICTIONARY_H_ | |
23 | #define DICTIONARY_H_ | |
24 | ||
25 | #include <collections/enumerator.h> | |
26 | ||
27 | typedef struct dictionary_t dictionary_t; | |
28 | ||
29 | /** | |
30 | * Interface for read-only dictionaries. | |
31 | */ | |
32 | struct dictionary_t { | |
33 | ||
34 | /** | |
35 | * Create an enumerator over the key/value pairs in the dictionary. | |
36 | * | |
37 | * @return enumerator over (const void *key, void *value) | |
38 | */ | |
39 | enumerator_t *(*create_enumerator)(dictionary_t *this); | |
40 | ||
41 | /** | |
42 | * Returns the value with the given key, if the dictionary contains such an | |
43 | * entry, otherwise NULL is returned. | |
44 | * | |
45 | * @param key the key of the requested value | |
46 | * @return the value, NULL if not found | |
47 | */ | |
48 | void *(*get)(dictionary_t *this, const void *key); | |
49 | ||
50 | /** | |
51 | * Destroys a dictionary object. | |
52 | */ | |
53 | void (*destroy)(dictionary_t *this); | |
54 | }; | |
55 | ||
56 | #endif /** DICTIONARY_H_ @}*/ |