Data Structures | Defines | Typedefs | Functions

# hashmap.c File Reference

`#include "wizard/studio.h"`
`#include "wizard/exception.h"`
`#include "wizard/exception-private.h"`
`#include "wizard/hash.h"`
`#include "wizard/hashmap.h"`
`#include "wizard/memory_.h"`
`#include "wizard/semaphore.h"`
`#include "wizard/string_.h"`

## Data Structures
struct | _ElementInfo
struct | _EntryInfo
struct | _LinkedListInfo
struct | _HashmapInfo
## Defines
#define | MaxCapacities 20
## Typedefs
typedef struct _ElementInfo | ElementInfo
typedef struct _EntryInfo | EntryInfo
## Functions
WizardExport WizardBooleanType | AppendValueToLinkedList (LinkedListInfo *list_info, const void *value)
WizardExport void | ClearLinkedList (LinkedListInfo *list_info, void *(*relinquish_value)(void *))
WizardExport WizardBooleanType | CompareHashmapString (const void *target, const void *source)
WizardExport WizardBooleanType | CompareHashmapStringInfo (const void *target, const void *source)
WizardExport HashmapInfo * | DestroyHashmap (HashmapInfo *hashmap_info)
WizardExport LinkedListInfo * | DestroyLinkedList (LinkedListInfo *list_info, void *(*relinquish_value)(void *))
WizardExport void * | GetLastValueInLinkedList (LinkedListInfo *list_info)
WizardExport void * | GetNextKeyInHashmap (HashmapInfo *hashmap_info)
WizardExport void * | GetNextValueInHashmap (HashmapInfo *hashmap_info)
WizardExport void * | GetNextValueInLinkedList (LinkedListInfo *list_info)
WizardExport size_t | GetNumberOfEntriesInHashmap (const HashmapInfo *hashmap_info)
WizardExport size_t | GetNumberOfElementsInLinkedList (const LinkedListInfo *list_info)
WizardExport void * | GetValueFromHashmap (HashmapInfo *hashmap_info, const void *key)
WizardExport void * | GetValueFromLinkedList (LinkedListInfo *list_info, const size_t index)
WizardExport size_t | HashPointerType (const void *pointer)
WizardExport size_t | HashStringType (const void *string)
WizardExport size_t | HashStringInfoType (const void *string)
WizardExport WizardBooleanType | InsertValueInLinkedList (LinkedListInfo *list_info, const size_t index, const void *value)
WizardExport WizardBooleanType | InsertValueInSortedLinkedList (LinkedListInfo *list_info, int(*compare)(const void *, const void *), void **replace, const void *value)
WizardExport WizardBooleanType | IsHashmapEmpty (const HashmapInfo *hashmap_info)
WizardExport WizardBooleanType | IsLinkedListEmpty (const LinkedListInfo *list_info)
WizardExport WizardBooleanType | LinkedListToArray (LinkedListInfo *list_info, void **array)
WizardExport HashmapInfo * | NewHashmap (const size_t capacity, size_t(*hash)(const void *), WizardBooleanType(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
WizardExport LinkedListInfo * | NewLinkedList (const size_t capacity)
static WizardBooleanType | IncreaseHashmapCapacity (HashmapInfo *hashmap_info)
WizardExport WizardBooleanType | PutEntryInHashmap (HashmapInfo *hashmap_info, const void *key, const void *value)
WizardExport void * | RemoveElementByValueFromLinkedList (LinkedListInfo *list_info, const void *value)
WizardExport void * | RemoveElementFromLinkedList (LinkedListInfo *list_info, const size_t index)
WizardExport void * | RemoveEntryFromHashmap (HashmapInfo *hashmap_info, const void *key)
WizardExport void * | RemoveLastElementFromLinkedList (LinkedListInfo *list_info)
WizardExport void | ResetHashmapIterator (HashmapInfo *hashmap_info)
WizardExport void | ResetLinkedListIterator (LinkedListInfo *list_info)

## Define Documentation

#define MaxCapacities 20

## Typedef Documentation

typedef struct _ElementInfo ElementInfo

typedef struct _EntryInfo EntryInfo

## Function Documentation

WizardExport WizardBooleanType AppendValueToLinkedList | ( | LinkedListInfo * | list_info,
|  | const void * | value |
| ) |  |  |

References AcquireWizardMemory(), _LinkedListInfo::capacity, _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _LinkedListInfo::next, _ElementInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, WizardSignature, and WizardTrue.

Referenced by GetConfigureOptions(), GetConfigurePaths(), LoadConfigureList(), LoadConfigureLists(), LoadLogList(), LoadLogLists(), LoadMimeList(), and ThrowException().

WizardExport void ClearLinkedList | ( | LinkedListInfo * | list_info,
|  | void *(*)(void *) | relinquish_value |
| ) |  |  |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _LinkedListInfo::next, _ElementInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

WizardExport WizardBooleanType CompareHashmapString | ( | const void * | target,
|  | const void * | source |
| ) |  |  |

References WizardTrue.

WizardExport WizardBooleanType CompareHashmapStringInfo | ( | const void * | target,
|  | const void * | source |
| ) |  |  |

References CompareStringInfo(), and WizardTrue.

WizardExport HashmapInfo* DestroyHashmap | ( | HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::capacity, _HashmapInfo::debug, DestroyLinkedList(), DestroySemaphoreInfo(), GetNextValueInLinkedList(), GetWizardModule, _LinkedListInfo::head, _EntryInfo::key, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, _LinkedListInfo::next, _HashmapInfo::relinquish_key, _HashmapInfo::relinquish_value, RelinquishWizardMemory(), _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _EntryInfo::value, WizardFalse, and WizardSignature.

WizardExport LinkedListInfo* DestroyLinkedList | ( | LinkedListInfo * | list_info,
|  | void *(*)(void *) | relinquish_value |
| ) |  |  |

References _LinkedListInfo::debug, DestroySemaphoreInfo(), GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by ConfigureComponentTerminus(), DestroyConfigureOptions(), DestroyExceptionInfo(), DestroyHashmap(), GetConfigureOptions(), LogComponentTerminus(), and MimeComponentTerminus().

WizardExport void* GetLastValueInLinkedList | ( | LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, LockSemaphoreInfo(), LogWizardEvent(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by ThrowException().

WizardExport void* GetNextKeyInHashmap | ( | HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::capacity, _HashmapInfo::debug, GetNextValueInLinkedList(), GetWizardModule, _LinkedListInfo::head, _HashmapInfo::head_of_list, _EntryInfo::key, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, _LinkedListInfo::next, _HashmapInfo::next, _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), WizardFalse, and WizardSignature.

WizardExport void* GetNextValueInHashmap | ( | HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::capacity, _HashmapInfo::debug, GetNextValueInLinkedList(), GetWizardModule, _LinkedListInfo::head, _HashmapInfo::head_of_list, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, _LinkedListInfo::next, _HashmapInfo::next, _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _EntryInfo::value, WizardFalse, and WizardSignature.

WizardExport void* GetNextValueInLinkedList | ( | LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, GetWizardModule, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by CatchException(), DestroyHashmap(), GetConfigureInfo(), GetConfigureInfoList(), GetConfigureList(), GetConfigureOptions(), GetLogInfo(), GetLogInfoList(), GetLogList(), GetMimeInfo(), GetMimeInfoList(), GetMimeList(), GetNextKeyInHashmap(), GetNextValueInHashmap(), GetValueFromHashmap(), InheritException(), LoadConfigureLists(), LoadLogLists(), LoadMimeLists(), PutEntryInHashmap(), and RemoveEntryFromHashmap().

WizardExport size_t GetNumberOfElementsInLinkedList | ( | const LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, LogWizardEvent(), _LinkedListInfo::signature, TraceEvent, WizardFalse, and WizardSignature.

Referenced by GetConfigureInfoList(), GetConfigureList(), GetConfigureOptions(), GetLogInfoList(), GetLogList(), GetMimeInfoList(), and GetMimeList().

WizardExport size_t GetNumberOfEntriesInHashmap | ( | const HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::debug, _HashmapInfo::entries, GetWizardModule, LogWizardEvent(), _HashmapInfo::signature, TraceEvent, WizardFalse, and WizardSignature.

WizardExport void* GetValueFromHashmap | ( | HashmapInfo * | hashmap_info,
|  | const void * | key |
| ) |  |  |

References _HashmapInfo::capacity, _HashmapInfo::compare, _HashmapInfo::debug, GetNextValueInLinkedList(), GetWizardModule, _EntryInfo::hash, _HashmapInfo::hash, _LinkedListInfo::head, _EntryInfo::key, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, _LinkedListInfo::next, _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _EntryInfo::value, WizardFalse, WizardSignature, and WizardTrue.

WizardExport void* GetValueFromLinkedList | ( | LinkedListInfo * | list_info,
|  | const size_t | index |
| ) |  |  |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by GetConfigureInfo(), GetLogInfo(), GetMimeInfo(), and SetLogEventMask().

WizardExport size_t HashPointerType | ( | const void * | pointer | ) |

WizardExport size_t HashStringInfoType | ( | const void * | string | ) |

References GetStringInfoDatum(), and GetStringInfoLength().

WizardExport size_t HashStringType | ( | const void * | string | ) |

References AcquireHashInfo(), CRC64Hash, DestroyHashInfo(), FinalizeHash(), GetHashDigest(), GetStringInfoDatum(), GetStringInfoLength(), InitializeHash(), StringToStringInfo(), and UpdateHash().

static WizardBooleanType IncreaseHashmapCapacity | ( | HashmapInfo * | hashmap_info | ) | `[static]`

References AcquireQuantumMemory(), _HashmapInfo::capacity, DestroySemaphoreInfo(), _LinkedListInfo::elements, _EntryInfo::hash, _LinkedListInfo::head, LockSemaphoreInfo(), _HashmapInfo::map, NewLinkedList(), _LinkedListInfo::next, _ElementInfo::next, RelinquishWizardMemory(), ResetWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardTrue.

Referenced by PutEntryInHashmap().

WizardExport WizardBooleanType InsertValueInLinkedList | ( | LinkedListInfo * | list_info,
|  | const size_t | index,
|  | const void * | value |
| ) |  |  |

References AcquireWizardMemory(), _LinkedListInfo::capacity, _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _LinkedListInfo::next, _ElementInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, WizardSignature, and WizardTrue.

Referenced by GetConfigureInfo(), GetLogInfo(), GetMimeInfo(), and PutEntryInHashmap().

WizardExport WizardBooleanType InsertValueInSortedLinkedList | ( | LinkedListInfo * | list_info,
|  | int(*)(const void *, const void *) | compare,
|  | void ** | replace,
|  | const void * | value |
| ) |  |  |

References AcquireWizardMemory(), _LinkedListInfo::capacity, _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, WizardSignature, and WizardTrue.

WizardExport WizardBooleanType IsHashmapEmpty | ( | const HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::debug, _HashmapInfo::entries, GetWizardModule, LogWizardEvent(), _HashmapInfo::signature, TraceEvent, WizardFalse, WizardSignature, and WizardTrue.

WizardExport WizardBooleanType IsLinkedListEmpty | ( | const LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, LogWizardEvent(), _LinkedListInfo::signature, TraceEvent, WizardFalse, WizardSignature, and WizardTrue.

Referenced by GetConfigureInfo(), GetLogInfo(), GetMimeInfo(), IsEventLogging(), and LoadMimeLists().

WizardExport WizardBooleanType LinkedListToArray | ( | LinkedListInfo * | list_info,
|  | void ** | array |
| ) |  |  |

References _LinkedListInfo::debug, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, WizardSignature, and WizardTrue.

WizardExport HashmapInfo* NewHashmap | ( | const size_t | capacity,
|  | size_t(*)(const void *) | hash,
|  | WizardBooleanType(*)(const void *, const void *) | compare,
|  | void *(*)(void *) | relinquish_key,
|  | void *(*)(void *) | relinquish_value |
| ) |  |  |

References AcquireQuantumMemory(), AcquireWizardMemory(), AllocateSemaphoreInfo(), CacheDomain, _HashmapInfo::capacity, _HashmapInfo::compare, _HashmapInfo::debug, _HashmapInfo::entries, _HashmapInfo::hash, IsEventLogging(), _HashmapInfo::map, MemoryError, _HashmapInfo::relinquish_key, _HashmapInfo::relinquish_value, ResetWizardMemory(), _HashmapInfo::semaphore, _HashmapInfo::signature, and ThrowWizardFatalError.

WizardExport LinkedListInfo* NewLinkedList | ( | const size_t | capacity | ) |

References AcquireWizardMemory(), AllocateSemaphoreInfo(), CacheDomain, _LinkedListInfo::capacity, _LinkedListInfo::debug, _LinkedListInfo::elements, _LinkedListInfo::head, MemoryError, _LinkedListInfo::next, ResetWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, and ThrowWizardFatalError.

Referenced by GetConfigureOptions(), GetConfigurePaths(), GetExceptionInfo(), IncreaseHashmapCapacity(), LoadConfigureList(), LoadConfigureLists(), LoadLogList(), LoadLogLists(), LoadMimeList(), and PutEntryInHashmap().

WizardExport WizardBooleanType PutEntryInHashmap | ( | HashmapInfo * | hashmap_info,
|  | const void * | key,
|  | const void * | value |
| ) |  |  |

References AcquireWizardMemory(), _HashmapInfo::capacity, _HashmapInfo::compare, _HashmapInfo::debug, _LinkedListInfo::elements, _HashmapInfo::entries, GetNextValueInLinkedList(), GetWizardModule, _HashmapInfo::hash, _EntryInfo::hash, _LinkedListInfo::head, IncreaseHashmapCapacity(), InsertValueInLinkedList(), _EntryInfo::key, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, NewLinkedList(), _LinkedListInfo::next, _HashmapInfo::relinquish_key, _HashmapInfo::relinquish_value, RelinquishWizardMemory(), RemoveElementFromLinkedList(), _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _EntryInfo::value, WizardFalse, WizardSignature, and WizardTrue.

WizardExport void* RemoveElementByValueFromLinkedList | ( | LinkedListInfo * | list_info,
|  | const void * | value |
| ) |  |  |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by GetConfigureInfo(), GetConfigurePaths(), GetLogInfo(), and GetMimeInfo().

WizardExport void* RemoveElementFromLinkedList | ( | LinkedListInfo * | list_info,
|  | const size_t | index |
| ) |  |  |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by PutEntryInHashmap(), and RemoveEntryFromHashmap().

WizardExport void* RemoveEntryFromHashmap | ( | HashmapInfo * | hashmap_info,
|  | const void * | key |
| ) |  |  |

References _HashmapInfo::capacity, _HashmapInfo::compare, _HashmapInfo::debug, _HashmapInfo::entries, GetNextValueInLinkedList(), GetWizardModule, _EntryInfo::hash, _HashmapInfo::hash, _LinkedListInfo::head, _EntryInfo::key, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::map, _LinkedListInfo::next, _HashmapInfo::relinquish_key, RelinquishWizardMemory(), RemoveElementFromLinkedList(), _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), _EntryInfo::value, WizardFalse, WizardSignature, and WizardTrue.

WizardExport void* RemoveLastElementFromLinkedList | ( | LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, _LinkedListInfo::elements, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _ElementInfo::next, _LinkedListInfo::next, RelinquishWizardMemory(), _LinkedListInfo::semaphore, _LinkedListInfo::signature, _LinkedListInfo::tail, TraceEvent, UnlockSemaphoreInfo(), _ElementInfo::value, WizardFalse, and WizardSignature.

Referenced by ClearWizardException().

WizardExport void ResetHashmapIterator | ( | HashmapInfo * | hashmap_info | ) |

References _HashmapInfo::debug, GetWizardModule, _HashmapInfo::head_of_list, LockSemaphoreInfo(), LogWizardEvent(), _HashmapInfo::next, _HashmapInfo::semaphore, _HashmapInfo::signature, TraceEvent, UnlockSemaphoreInfo(), WizardFalse, and WizardSignature.

WizardExport void ResetLinkedListIterator | ( | LinkedListInfo * | list_info | ) |

References _LinkedListInfo::debug, GetWizardModule, _LinkedListInfo::head, LockSemaphoreInfo(), LogWizardEvent(), _LinkedListInfo::next, _LinkedListInfo::semaphore, _LinkedListInfo::signature, TraceEvent, UnlockSemaphoreInfo(), WizardFalse, and WizardSignature.

Referenced by CatchException(), GetConfigureInfo(), GetConfigureInfoList(), GetConfigureList(), GetConfigureOptions(), GetLogInfo(), GetLogInfoList(), GetLogList(), GetMimeInfo(), GetMimeInfoList(), GetMimeList(), and InheritException().