plibsys  0.0.4
phashtable.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2010-2016 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
57 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
58 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
59 #endif
60 
61 #ifndef PLIBSYS_HEADER_PHASHTABLE_H
62 #define PLIBSYS_HEADER_PHASHTABLE_H
63 
64 #include <pmacros.h>
65 #include <ptypes.h>
66 #include <plist.h>
67 
69 
71 typedef struct PHashTable_ PHashTable;
72 
81 
93  ppointer key,
94  ppointer value);
95 
105  pconstpointer key);
106 
117 
128 
135 
143  pconstpointer key);
144 
162  pconstpointer val,
163  PCompareFunc func);
164 
166 
167 #endif /* PLIBSYS_HEADER_PHASHTABLE_H */
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
P_LIB_API PList * p_hash_table_lookup_by_value(const PHashTable *table, pconstpointer val, PCompareFunc func)
Searches for a specifed key in the hash table by its value.
P_LIB_API PList * p_hash_table_keys(const PHashTable *table)
Gives a list of all the stored keys in the hash table.
P_LIB_API ppointer p_hash_table_lookup(const PHashTable *table, pconstpointer key)
Searches for a specifed key in the hash table.
pint(* PCompareFunc)(pconstpointer a, pconstpointer b)
Compares two values.
Definition: ptypes.h:1107
struct PHashTable_ PHashTable
Opaque data structure for a hash table.
Definition: phashtable.h:71
P_LIB_API PHashTable * p_hash_table_new(void)
Initializes a new hash table.
P_LIB_API void p_hash_table_remove(PHashTable *table, pconstpointer key)
Removes key from a hash table.
Miscellaneous macros.
Node for a singly linked list.
Definition: plist.h:96
void * ppointer
Type for a pointer.
Definition: ptypes.h:109
P_LIB_API void p_hash_table_insert(PHashTable *table, ppointer key, ppointer value)
Inserts a new key-value pair into a hash table.
const void * pconstpointer
Type for a const pointer.
Definition: ptypes.h:111
Singly linked list.
P_LIB_API void p_hash_table_free(PHashTable *table)
Frees a previously initialized PHashTable.
P_LIB_API PList * p_hash_table_values(const PHashTable *table)
Gives a list of all the stored values in the hash table.
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
Types definitions.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298