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
30 CPL_C_START
31
32/* Types */
33
35 typedef struct _CPLHashSet CPLHashSet;
36
38 typedef unsigned long (*CPLHashSetHashFunc)(const void *elt);
39
41 typedef int (*CPLHashSetEqualFunc)(const void *elt1, const void *elt2);
42
44 typedef void (*CPLHashSetFreeEltFunc)(void *elt);
45
47 typedef int (*CPLHashSetIterEltFunc)(void *elt, void *user_data);
48
49/* Functions */
50
51 CPLHashSet CPL_DLL *CPLHashSetNew(CPLHashSetHashFunc fnHashFunc,
52 CPLHashSetEqualFunc fnEqualFunc,
53 CPLHashSetFreeEltFunc fnFreeEltFunc);
54
55 void CPL_DLL CPLHashSetDestroy(CPLHashSet *set);
56
57 void CPL_DLL CPLHashSetClear(CPLHashSet *set);
58
59 int CPL_DLL CPLHashSetSize(const CPLHashSet *set);
60
61 void CPL_DLL CPLHashSetForeach(CPLHashSet *set,
62 CPLHashSetIterEltFunc fnIterFunc,
63 void *user_data);
64
65 int CPL_DLL CPLHashSetInsert(CPLHashSet *set, void *elt);
66
67 void CPL_DLL *CPLHashSetLookup(CPLHashSet *set, const void *elt);
68
69 int CPL_DLL CPLHashSetRemove(CPLHashSet *set, const void *elt);
70 int CPL_DLL CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt);
71
72 unsigned long CPL_DLL CPLHashSetHashPointer(const void *elt);
73
74 int CPL_DLL CPLHashSetEqualPointer(const void *elt1, const void *elt2);
75
76 unsigned long CPL_DLL CPLHashSetHashStr(const void *pszStr);
77
78 int CPL_DLL CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2);
79
80 CPL_C_END
81
82#endif /* CPL_HASH_SET_H_INCLUDED */
CPLHashSetRemove
int CPLHashSetRemove(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition cpl_hash_set.cpp:453
CPLHashSetHashFunc
unsigned long(* CPLHashSetHashFunc)(const void *elt)
CPLHashSetHashFunc.
Definition cpl_hash_set.h:38
CPLHashSetHashPointer
unsigned long CPLHashSetHashPointer(const void *elt)
Hash function for an arbitrary pointer.
Definition cpl_hash_set.cpp:491
CPLHashSet
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition cpl_hash_set.h:35
CPLHashSetEqualPointer
int CPLHashSetEqualPointer(const void *elt1, const void *elt2)
Equality function for arbitrary pointers.
Definition cpl_hash_set.cpp:510
CPLHashSetLookup
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
CPLHashSetDestroy
void CPLHashSetDestroy(CPLHashSet *set)
Destroys an allocated hash set.
Definition cpl_hash_set.cpp:186
CPLHashSetClear
void CPLHashSetClear(CPLHashSet *set)
Clear all elements from a hash set.
Definition cpl_hash_set.cpp:207
CPLHashSetSize
int CPLHashSetSize(const CPLHashSet *set)
Returns the number of elements inserted in the hash set.
Definition cpl_hash_set.cpp:105
CPLHashSetInsert
int CPLHashSetInsert(CPLHashSet *set, void *elt)
Inserts an element into a hash set.
Definition cpl_hash_set.cpp:334
CPLHashSetHashStr
unsigned long CPLHashSetHashStr(const void *pszStr)
Hash function for a zero-terminated string.
Definition cpl_hash_set.cpp:528
CPLHashSetForeach
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
CPLHashSetNew
CPLHashSet * CPLHashSetNew(CPLHashSetHashFunc fnHashFunc, CPLHashSetEqualFunc fnEqualFunc, CPLHashSetFreeEltFunc fnFreeEltFunc)
Creates a new hash set.
Definition cpl_hash_set.cpp:70
CPLHashSetIterEltFunc
int(* CPLHashSetIterEltFunc)(void *elt, void *user_data)
CPLHashSetIterEltFunc.
Definition cpl_hash_set.h:47
CPLHashSetFreeEltFunc
void(* CPLHashSetFreeEltFunc)(void *elt)
CPLHashSetFreeEltFunc.
Definition cpl_hash_set.h:44
CPLHashSetEqualStr
int CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2)
Equality function for strings.
Definition cpl_hash_set.cpp:556
CPLHashSetEqualFunc
int(* CPLHashSetEqualFunc)(const void *elt1, const void *elt2)
CPLHashSetEqualFunc.
Definition cpl_hash_set.h:41
CPLHashSetRemoveDeferRehash
int CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition cpl_hash_set.cpp:474
cpl_port.h
Core portability definitions for CPL.
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285