GDAL
cpl_hash_set.h
Go to the documentation of this file.
1/**********************************************************************
2 *
3 * Name: cpl_hash_set.h
4 * Project: CPL - Common Portability Library
5 * Purpose: Hash set functions.
6 * Author: Even Rouault, <even dot rouault at spatialys.com>
7 *
8 **********************************************************************
9 * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef CPL_HASH_SET_H_INCLUDED
15#define CPL_HASH_SET_H_INCLUDED
16
17#include "cpl_port.h"
18
29
31
32/* Types */
33
35typedef struct _CPLHashSet CPLHashSet;
36
38typedef unsigned long (*CPLHashSetHashFunc)(const void *elt);
39
41typedef int (*CPLHashSetEqualFunc)(const void *elt1, const void *elt2);
42
44typedef void (*CPLHashSetFreeEltFunc)(void *elt);
45
47typedef int (*CPLHashSetIterEltFunc)(void *elt, void *user_data);
48
49/* Functions */
50
52 CPLHashSetEqualFunc fnEqualFunc,
53 CPLHashSetFreeEltFunc fnFreeEltFunc);
54
55void CPL_DLL CPLHashSetDestroy(CPLHashSet *set);
56
57void CPL_DLL CPLHashSetClear(CPLHashSet *set);
58
59int CPL_DLL CPLHashSetSize(const CPLHashSet *set);
60
61void CPL_DLL CPLHashSetForeach(CPLHashSet *set,
62 CPLHashSetIterEltFunc fnIterFunc,
63 void *user_data);
64
65int CPL_DLL CPLHashSetInsert(CPLHashSet *set, void *elt);
66
67void CPL_DLL *CPLHashSetLookup(CPLHashSet *set, const void *elt);
68
69int CPL_DLL CPLHashSetRemove(CPLHashSet *set, const void *elt);
70int CPL_DLL CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt);
71
72unsigned long CPL_DLL CPLHashSetHashPointer(const void *elt);
73
74int CPL_DLL CPLHashSetEqualPointer(const void *elt1, const void *elt2);
75
76unsigned long CPL_DLL CPLHashSetHashStr(const void *pszStr);
77
78int CPL_DLL CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2);
79
81
82#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:453
unsigned long(* CPLHashSetHashFunc)(const void *elt)
CPLHashSetHashFunc.
Definition cpl_hash_set.h:38
unsigned long CPLHashSetHashPointer(const void *elt)
Hash function for an arbitrary pointer.
Definition cpl_hash_set.cpp:491
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition cpl_hash_set.h:35
int CPLHashSetEqualPointer(const void *elt1, const void *elt2)
Equality function for arbitrary pointers.
Definition cpl_hash_set.cpp:510
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:384
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:207
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:334
unsigned long CPLHashSetHashStr(const void *pszStr)
Hash function for a zero-terminated string.
Definition cpl_hash_set.cpp:528
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:240
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:47
void(* CPLHashSetFreeEltFunc)(void *elt)
CPLHashSetFreeEltFunc.
Definition cpl_hash_set.h:44
int CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2)
Equality function for strings.
Definition cpl_hash_set.cpp:556
int(* CPLHashSetEqualFunc)(const void *elt1, const void *elt2)
CPLHashSetEqualFunc.
Definition cpl_hash_set.h:41
int CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition cpl_hash_set.cpp:474
Core portability definitions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285