MagickCore  6.9.12-38
Convert, Edit, Or Compose Bitmap Images
hashmap.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2021 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore hash methods.
17 */
18 #ifndef MAGICKCORE_HASHMAP_H
19 #define MAGICKCORE_HASHMAP_H
20 
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24 
25 #define SmallHashmapSize 17
26 #define MediumHashmapSize 509
27 #define LargeHashmapSize 8191
28 #define HugeHashmapSize 131071
29 
30 typedef struct _HashmapInfo
32 
33 typedef struct _LinkedListInfo
35 
38  *NewHashmap(const size_t,size_t (*)(const void *),MagickBooleanType (*)
39  (const void *,const void *),void *(*)(void *),void *(*)(void *));
40 
42  *DestroyLinkedList(LinkedListInfo *,void *(*)(void *)),
43  *NewLinkedList(const size_t);
44 
47  CompareHashmapString(const void *,const void *),
48  CompareHashmapStringInfo(const void *,const void *),
49  InsertValueInLinkedList(LinkedListInfo *,const size_t,const void *),
51  int (*)(const void *,const void *),void **,const void *),
55  PutEntryInHashmap(HashmapInfo *,const void *,const void *);
56 
57 extern MagickExport size_t
60  HashPointerType(const void *),
61  HashStringType(const void *),
62  HashStringInfoType(const void *);
63 
64 extern MagickExport void
65  ClearLinkedList(LinkedListInfo *,void *(*)(void *)),
70  *GetValueFromHashmap(HashmapInfo *,const void *),
78 
79 #if defined(__cplusplus) || defined(c_plusplus)
80 }
81 #endif
82 
83 #endif
DestroyHashmap
MagickExport HashmapInfo * DestroyHashmap(HashmapInfo *hashmap_info)
Definition: hashmap.c:330
_EntryInfo::hash
size_t hash
Definition: hashmap.c:70
LockSemaphoreInfo
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport
#define MagickExport
Definition: method-attribute.h:80
_HashmapInfo
Definition: hashmap.c:96
LinkedListToArray
MagickExport MagickBooleanType LinkedListToArray(LinkedListInfo *list_info, void **array)
Definition: hashmap.c:1238
CompareHashmapString
MagickExport MagickBooleanType CompareHashmapString(const void *, const void *)
NewHashmap
MagickExport HashmapInfo * NewHashmap(const size_t, size_t(*)(const void *), MagickBooleanType(*)(const void *, const void *), void *(*)(void *), void *(*)(void *))
GetNextValueInHashmap
MagickExport void * GetNextValueInHashmap(HashmapInfo *hashmap_info)
Definition: hashmap.c:545
IsLinkedListEmpty
MagickExport MagickBooleanType IsLinkedListEmpty(const LinkedListInfo *list_info)
Definition: hashmap.c:1205
GetValueFromLinkedList
MagickExport void * GetValueFromLinkedList(LinkedListInfo *list_info, const size_t index)
Definition: hashmap.c:788
RemoveLastElementFromLinkedList
MagickExport void * RemoveLastElementFromLinkedList(LinkedListInfo *)
ClearLinkedList
MagickExport void ClearLinkedList(LinkedListInfo *, void *(*)(void *))
MagickCoreSignature
#define MagickCoreSignature
Definition: method-attribute.h:86
RemoveEntryFromHashmap
MagickExport void * RemoveEntryFromHashmap(HashmapInfo *hashmap_info, const void *key)
Definition: hashmap.c:1741
_EntryInfo::key
void * key
Definition: hashmap.c:73
_HashmapInfo::map
LinkedListInfo ** map
Definition: hashmap.c:116
DestroyLinkedList
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
Definition: hashmap.c:398
InsertValueInSortedLinkedList
MagickExport MagickBooleanType InsertValueInSortedLinkedList(LinkedListInfo *, int(*)(const void *, const void *), void **, const void *)
_ElementInfo::value
void * value
Definition: hashmap.c:61
HashStringType
MagickExport size_t HashStringType(const void *)
ResetLinkedListIterator
MagickExport void ResetLinkedListIterator(LinkedListInfo *list_info)
Definition: hashmap.c:1921
ResetHashmapIterator
MagickExport void ResetHashmapIterator(HashmapInfo *hashmap_info)
Definition: hashmap.c:1887
_HashmapInfo::signature
size_t signature
Definition: hashmap.c:122
ResetHashmapIterator
MagickExport void ResetHashmapIterator(HashmapInfo *)
GetValueFromHashmap
MagickExport void * GetValueFromHashmap(HashmapInfo *, const void *)
_LinkedListInfo::semaphore
SemaphoreInfo * semaphore
Definition: hashmap.c:89
CompareHashmapStringInfo
MagickExport MagickBooleanType CompareHashmapStringInfo(const void *, const void *)
PutEntryInHashmap
MagickExport MagickBooleanType PutEntryInHashmap(HashmapInfo *hashmap_info, const void *key, const void *value)
Definition: hashmap.c:1495
GetNumberOfEntriesInHashmap
MagickExport size_t GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
Definition: hashmap.c:647
IsHashmapEmpty
MagickExport MagickBooleanType IsHashmapEmpty(const HashmapInfo *hashmap_info)
Definition: hashmap.c:1176
_EntryInfo::value
void * value
Definition: hashmap.c:74
string_.h
_LinkedListInfo::tail
ElementInfo * tail
Definition: hashmap.c:85
_HashmapInfo::semaphore
SemaphoreInfo * semaphore
Definition: hashmap.c:119
MagickTrue
@ MagickTrue
Definition: magick-type.h:201
GetNextKeyInHashmap
MagickExport void * GetNextKeyInHashmap(HashmapInfo *hashmap_info)
Definition: hashmap.c:484
StringToStringInfo
MagickExport StringInfo * StringToStringInfo(const char *string)
Definition: string.c:2459
semaphore.h
InsertValueInSortedLinkedList
MagickExport MagickBooleanType InsertValueInSortedLinkedList(LinkedListInfo *list_info, int(*compare)(const void *, const void *), void **replace, const void *value)
Definition: hashmap.c:1091
RemoveElementFromLinkedList
MagickExport void * RemoveElementFromLinkedList(LinkedListInfo *list_info, const size_t index)
Definition: hashmap.c:1669
GetValueFromHashmap
MagickExport void * GetValueFromHashmap(HashmapInfo *hashmap_info, const void *key)
Definition: hashmap.c:711
HashStringType
MagickExport size_t HashStringType(const void *string)
Definition: hashmap.c:884
HashPointerType
MagickExport size_t HashPointerType(const void *)
GetLastValueInLinkedList
MagickExport void * GetLastValueInLinkedList(LinkedListInfo *)
hashmap.h
GetNextValueInLinkedList
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *)
_HashmapInfo::entries
size_t entries
Definition: hashmap.c:109
AcquireMagickMemory
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:552
ClearLinkedList
MagickExport void ClearLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
Definition: hashmap.c:204
_HashmapInfo::capacity
size_t capacity
Definition: hashmap.c:108
SemaphoreInfo
Definition: semaphore.c:61
AppendValueToLinkedList
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *, const void *)
HashPointerType
MagickExport size_t HashPointerType(const void *pointer)
Definition: hashmap.c:848
_HashmapInfo::hash
size_t(* hash)(const void *)
Definition: hashmap.c:98
GetNextValueInHashmap
MagickExport void * GetNextValueInHashmap(HashmapInfo *)
EntryInfo
struct _EntryInfo EntryInfo
LocaleCompare
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
HashStringInfoType
MagickExport size_t HashStringInfoType(const void *string_info)
Definition: hashmap.c:937
RemoveElementFromLinkedList
MagickExport void * RemoveElementFromLinkedList(LinkedListInfo *, const size_t)
_LinkedListInfo
Definition: hashmap.c:78
locale_.h
MagickFalse
@ MagickFalse
Definition: magick-type.h:200
UpdateSignature
MagickExport void UpdateSignature(SignatureInfo *, const StringInfo *)
Definition: signature.c:750
LinkedListToArray
MagickExport MagickBooleanType LinkedListToArray(LinkedListInfo *, void **)
GetNumberOfElementsInLinkedList
MagickExport size_t GetNumberOfElementsInLinkedList(const LinkedListInfo *list_info)
Definition: hashmap.c:679
_HashmapInfo::compare
MagickBooleanType(* compare)(const void *, const void *)
Definition: hashmap.c:101
AppendValueToLinkedList
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
Definition: hashmap.c:150
DestroyLinkedList
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *, void *(*)(void *))
_SignatureInfo
Definition: signature.c:65
AllocateSemaphoreInfo
MagickExport SemaphoreInfo * AllocateSemaphoreInfo(void)
Definition: semaphore.c:192
GetNextKeyInHashmap
MagickExport void * GetNextKeyInHashmap(HashmapInfo *)
_HashmapInfo::relinquish_key
void *(* relinquish_key)(void *)
Definition: hashmap.c:104
FinalizeSignature
MagickExport void FinalizeSignature(SignatureInfo *)
DestroyHashmap
MagickExport HashmapInfo * DestroyHashmap(HashmapInfo *)
DestroySignatureInfo
MagickExport SignatureInfo * DestroySignatureInfo(SignatureInfo *)
Definition: signature.c:170
_LinkedListInfo::signature
size_t signature
Definition: hashmap.c:92
_HashmapInfo::relinquish_value
void *(*) *(* relinquish_value)(void *)
Definition: hashmap.c:105
ResetLinkedListIterator
MagickExport void ResetLinkedListIterator(LinkedListInfo *)
Definition: hashmap.c:1921
_ElementInfo
Definition: draw.c:134
RemoveElementByValueFromLinkedList
MagickExport void * RemoveElementByValueFromLinkedList(LinkedListInfo *, const void *)
CompareHashmapStringInfo
MagickExport MagickBooleanType CompareHashmapStringInfo(const void *target, const void *source)
Definition: hashmap.c:296
DestroySemaphoreInfo
MagickExport void DestroySemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
MagickBooleanType
MagickBooleanType
Definition: magick-type.h:199
GetLastValueInLinkedList
MagickExport void * GetLastValueInLinkedList(LinkedListInfo *list_info)
Definition: hashmap.c:447
IncreaseHashmapCapacity
static MagickBooleanType IncreaseHashmapCapacity(HashmapInfo *hashmap_info)
Definition: hashmap.c:1411
GetNextValueInLinkedList
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
Definition: hashmap.c:606
RelinquishMagickMemory
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1162
GetNumberOfEntriesInHashmap
MagickExport size_t GetNumberOfEntriesInHashmap(const HashmapInfo *)
studio.h
_LinkedListInfo::elements
size_t elements
Definition: hashmap.c:81
CompareStringInfo
MagickExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
Definition: string.c:378
ElementInfo
struct _ElementInfo ElementInfo
PutEntryInHashmap
MagickExport MagickBooleanType PutEntryInHashmap(HashmapInfo *, const void *, const void *)
Definition: hashmap.c:1495
NewLinkedList
MagickExport LinkedListInfo * NewLinkedList(const size_t)
Definition: hashmap.c:1363
GetNumberOfElementsInLinkedList
MagickExport size_t GetNumberOfElementsInLinkedList(const LinkedListInfo *)
memory_.h
GetValueFromLinkedList
MagickExport void * GetValueFromLinkedList(LinkedListInfo *, const size_t)
GetStringInfoDatum
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1196
signature-private.h
_HashmapInfo::head_of_list
MagickBooleanType head_of_list
Definition: hashmap.c:113
MaxCapacities
#define MaxCapacities
AcquireSignatureInfo
MagickExport SignatureInfo * AcquireSignatureInfo(void)
_LinkedListInfo::next
ElementInfo * next
Definition: hashmap.c:86
RemoveEntryFromHashmap
MagickExport void * RemoveEntryFromHashmap(HashmapInfo *, const void *)
RemoveLastElementFromLinkedList
MagickExport void * RemoveLastElementFromLinkedList(LinkedListInfo *list_info)
Definition: hashmap.c:1828
NewLinkedList
MagickExport LinkedListInfo * NewLinkedList(const size_t capacity)
Definition: hashmap.c:1363
exception-private.h
ThrowFatalException
#define ThrowFatalException(severity, tag)
Definition: exception-private.h:42
UnlockSemaphoreInfo
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:449
exception.h
DestroyStringInfo
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:848
_EntryInfo
Definition: hashmap.c:68
_LinkedListInfo::head
ElementInfo * head
Definition: hashmap.c:84
GetSignatureDigest
MagickExport const StringInfo * GetSignatureDigest(const SignatureInfo *)
Definition: signature.c:326
CompareHashmapString
MagickExport MagickBooleanType CompareHashmapString(const void *target, const void *source)
Definition: hashmap.c:258
_LinkedListInfo::capacity
size_t capacity
Definition: hashmap.c:80
_HashmapInfo::next
size_t next
Definition: hashmap.c:110
RemoveElementByValueFromLinkedList
MagickExport void * RemoveElementByValueFromLinkedList(LinkedListInfo *list_info, const void *value)
Definition: hashmap.c:1597
InsertValueInLinkedList
MagickExport MagickBooleanType InsertValueInLinkedList(LinkedListInfo *, const size_t, const void *)
NewHashmap
MagickExport HashmapInfo * NewHashmap(const size_t capacity, size_t(*hash)(const void *), MagickBooleanType(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
Definition: hashmap.c:1305
ResourceLimitFatalError
@ ResourceLimitFatalError
Definition: exception.h:78
_ElementInfo::next
struct _ElementInfo * next
Definition: hashmap.c:63
_StringInfo
Definition: string_.h:30
HashStringInfoType
MagickExport size_t HashStringInfoType(const void *)
Definition: hashmap.c:937
InsertValueInLinkedList
MagickExport MagickBooleanType InsertValueInLinkedList(LinkedListInfo *list_info, const size_t index, const void *value)
Definition: hashmap.c:990
IsLinkedListEmpty
MagickExport MagickBooleanType IsLinkedListEmpty(const LinkedListInfo *)
AcquireQuantumMemory
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:665
IsHashmapEmpty
MagickExport MagickBooleanType IsHashmapEmpty(const HashmapInfo *)