GDAL
cpl_hash_set.h
Go to the documentation of this file.
1/**********************************************************************
2 * $Id$
3 *
4 * Name: cpl_hash_set.h
5 * Project: CPL - Common Portability Library
6 * Purpose: Hash set functions.
7 * Author: Even Rouault, <even dot rouault at spatialys.com>
8 *
9 **********************************************************************
10 * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef CPL_HASH_SET_H_INCLUDED
16#define CPL_HASH_SET_H_INCLUDED
17
18#include "cpl_port.h"
19
32
33/* Types */
34
36typedef struct _CPLHashSet CPLHashSet;
37
39typedef unsigned long (*CPLHashSetHashFunc)(const void *elt);
40
42typedef int (*CPLHashSetEqualFunc)(const void *elt1, const void *elt2);
43
45typedef void (*CPLHashSetFreeEltFunc)(void *elt);
46
48typedef int (*CPLHashSetIterEltFunc)(void *elt, void *user_data);
49
50/* Functions */
51
53 CPLHashSetEqualFunc fnEqualFunc,
54 CPLHashSetFreeEltFunc fnFreeEltFunc);
55
56void CPL_DLL CPLHashSetDestroy(CPLHashSet *set);
57
58void CPL_DLL CPLHashSetClear(CPLHashSet *set);
59
60int CPL_DLL CPLHashSetSize(const CPLHashSet *set);
61
62void CPL_DLL CPLHashSetForeach(CPLHashSet *set,
63 CPLHashSetIterEltFunc fnIterFunc,
64 void *user_data);
65
66int CPL_DLL CPLHashSetInsert(CPLHashSet *set, void *elt);
67
68void CPL_DLL *CPLHashSetLookup(CPLHashSet *set, const void *elt);
69
70int CPL_DLL CPLHashSetRemove(CPLHashSet *set, const void *elt);
71int CPL_DLL CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt);
72
73unsigned long CPL_DLL CPLHashSetHashPointer(const void *elt);
74
75int CPL_DLL CPLHashSetEqualPointer(const void *elt1, const void *elt2);
76
77unsigned long CPL_DLL CPLHashSetHashStr(const void *pszStr);
78
79int CPL_DLL CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2);
80
82
83#endif /* CPL_HASH_SET_H_INCLUDED */
int CPLHashSetRemove(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition: cpl_hash_set.cpp:454
unsigned long(* CPLHashSetHashFunc)(const void *elt)
CPLHashSetHashFunc.
Definition: cpl_hash_set.h:39
unsigned long CPLHashSetHashPointer(const void *elt)
Hash function for an arbitrary pointer.
Definition: cpl_hash_set.cpp:493
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:36
int CPLHashSetEqualPointer(const void *elt1, const void *elt2)
Equality function for arbitrary pointers.
Definition: cpl_hash_set.cpp:512
void * CPLHashSetLookup(CPLHashSet *set, const void *elt)
Returns the element found in the hash set corresponding to the element to look up The element must no...
Definition: cpl_hash_set.cpp:385
void CPLHashSetDestroy(CPLHashSet *set)
Destroys an allocated hash set.
Definition: cpl_hash_set.cpp:186
void CPLHashSetClear(CPLHashSet *set)
Clear all elements from a hash set.
Definition: cpl_hash_set.cpp:208
int CPLHashSetSize(const CPLHashSet *set)
Returns the number of elements inserted in the hash set.
Definition: cpl_hash_set.cpp:105
int CPLHashSetInsert(CPLHashSet *set, void *elt)
Inserts an element into a hash set.
Definition: cpl_hash_set.cpp:335
unsigned long CPLHashSetHashStr(const void *pszStr)
Hash function for a zero-terminated string.
Definition: cpl_hash_set.cpp:530
void CPLHashSetForeach(CPLHashSet *set, CPLHashSetIterEltFunc fnIterFunc, void *user_data)
Walk through the hash set and runs the provided function on all the elements.
Definition: cpl_hash_set.cpp:241
CPLHashSet * CPLHashSetNew(CPLHashSetHashFunc fnHashFunc, CPLHashSetEqualFunc fnEqualFunc, CPLHashSetFreeEltFunc fnFreeEltFunc)
Creates a new hash set.
Definition: cpl_hash_set.cpp:70
int(* CPLHashSetIterEltFunc)(void *elt, void *user_data)
CPLHashSetIterEltFunc.
Definition: cpl_hash_set.h:48
void(* CPLHashSetFreeEltFunc)(void *elt)
CPLHashSetFreeEltFunc.
Definition: cpl_hash_set.h:45
int CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2)
Equality function for strings.
Definition: cpl_hash_set.cpp:558
int(* CPLHashSetEqualFunc)(const void *elt1, const void *elt2)
CPLHashSetEqualFunc.
Definition: cpl_hash_set.h:42
int CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition: cpl_hash_set.cpp:476
Core portability definitions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:283
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:279