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
31 CPL_C_START
32
33/* Types */
34
36 typedef struct _CPLHashSet CPLHashSet;
37
39 typedef unsigned long (*CPLHashSetHashFunc)(const void *elt);
40
42 typedef int (*CPLHashSetEqualFunc)(const void *elt1, const void *elt2);
43
45 typedef void (*CPLHashSetFreeEltFunc)(void *elt);
46
48 typedef int (*CPLHashSetIterEltFunc)(void *elt, void *user_data);
49
50/* Functions */
51
52 CPLHashSet CPL_DLL *CPLHashSetNew(CPLHashSetHashFunc fnHashFunc,
53 CPLHashSetEqualFunc fnEqualFunc,
54 CPLHashSetFreeEltFunc fnFreeEltFunc);
55
56 void CPL_DLL CPLHashSetDestroy(CPLHashSet *set);
57
58 void CPL_DLL CPLHashSetClear(CPLHashSet *set);
59
60 int CPL_DLL CPLHashSetSize(const CPLHashSet *set);
61
62 void CPL_DLL CPLHashSetForeach(CPLHashSet *set,
63 CPLHashSetIterEltFunc fnIterFunc,
64 void *user_data);
65
66 int CPL_DLL CPLHashSetInsert(CPLHashSet *set, void *elt);
67
68 void CPL_DLL *CPLHashSetLookup(CPLHashSet *set, const void *elt);
69
70 int CPL_DLL CPLHashSetRemove(CPLHashSet *set, const void *elt);
71 int CPL_DLL CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt);
72
73 unsigned long CPL_DLL CPLHashSetHashPointer(const void *elt);
74
75 int CPL_DLL CPLHashSetEqualPointer(const void *elt1, const void *elt2);
76
77 unsigned long CPL_DLL CPLHashSetHashStr(const void *pszStr);
78
79 int CPL_DLL CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2);
80
81 CPL_C_END
82
83#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:454
CPLHashSetHashFunc
unsigned long(* CPLHashSetHashFunc)(const void *elt)
CPLHashSetHashFunc.
Definition cpl_hash_set.h:39
CPLHashSetHashPointer
unsigned long CPLHashSetHashPointer(const void *elt)
Hash function for an arbitrary pointer.
Definition cpl_hash_set.cpp:493
CPLHashSet
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition cpl_hash_set.h:36
CPLHashSetEqualPointer
int CPLHashSetEqualPointer(const void *elt1, const void *elt2)
Equality function for arbitrary pointers.
Definition cpl_hash_set.cpp:512
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:385
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:208
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:335
CPLHashSetHashStr
unsigned long CPLHashSetHashStr(const void *pszStr)
Hash function for a zero-terminated string.
Definition cpl_hash_set.cpp:530
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:241
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:48
CPLHashSetFreeEltFunc
void(* CPLHashSetFreeEltFunc)(void *elt)
CPLHashSetFreeEltFunc.
Definition cpl_hash_set.h:45
CPLHashSetEqualStr
int CPLHashSetEqualStr(const void *pszStr1, const void *pszStr2)
Equality function for strings.
Definition cpl_hash_set.cpp:558
CPLHashSetEqualFunc
int(* CPLHashSetEqualFunc)(const void *elt1, const void *elt2)
CPLHashSetEqualFunc.
Definition cpl_hash_set.h:42
CPLHashSetRemoveDeferRehash
int CPLHashSetRemoveDeferRehash(CPLHashSet *set, const void *elt)
Removes an element from a hash set.
Definition cpl_hash_set.cpp:476
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:283
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:279