97 (*
hash)(
const void *);
100 (*
compare)(
const void *,
const void *);
103 *(*relinquish_key)(
void *),
162 next->
value=(
void *) value;
166 list_info->
next=next;
168 list_info->
head=next;
171 list_info->
tail=next;
204 void *(*relinquish_value)(
void *))
215 next=list_info->
head;
218 if (relinquish_value != (
void *(*)(
void *)) NULL)
343 for (i=0; i < (ssize_t) hashmap_info->
capacity; i++)
345 list_info=hashmap_info->
map[i];
364 hashmap_info->
signature=(~WizardSignature);
368 return(hashmap_info);
398 void *(*relinquish_value)(
void *))
411 if (relinquish_value != (
void *(*)(
void *)) NULL)
454 return((
void *) NULL);
499 list_info=hashmap_info->
map[hashmap_info->
next];
516 hashmap_info->
next++;
519 return((
void *) NULL);
560 list_info=hashmap_info->
map[hashmap_info->
next];
577 hashmap_info->
next++;
580 return((
void *) NULL);
616 return((
void *) NULL);
728 return((
void *) NULL);
730 hash=hashmap_info->
hash(key);
731 list_info=hashmap_info->
map[hash % hashmap_info->
capacity];
738 if (entry->
hash == hash)
746 compare=hashmap_info->
compare(key,entry->
key);
758 return((
void *) NULL);
802 return((
void *) NULL);
810 if (index == (list_info->
elements-1))
816 next=list_info->
head;
817 for (i=0; i < (ssize_t) index; i++)
852 hash=(size_t) pointer;
853 hash+=(~(hash << 9));
904 if (hashmap_info == (
HashInfo *) NULL)
905 return((
size_t)
string);
1004 if ((index > list_info->
elements) ||
1010 next->
value=(
void *) value;
1016 list_info->
next=next;
1017 list_info->
head=next;
1018 list_info->
tail=next;
1024 if (list_info->
next == list_info->
head)
1025 list_info->
next=next;
1027 list_info->
head=next;
1033 list_info->
next=next;
1035 list_info->
tail=next;
1042 element=list_info->
head;
1044 for (i=1; i < (ssize_t) index; i++)
1046 element=element->
next;
1052 list_info->
next=next;
1093 LinkedListInfo *list_info,
int (*compare)(
const void *,
const void *),
1094 void **replace,
const void *value)
1107 if ((compare == (
int (*)(
const void *,
const void *)) NULL) ||
1108 (value == (
const void *) NULL))
1115 next->
value=(
void *) value;
1122 if ((i < 0) || ((replace != (
void **) NULL) && (i == 0)))
1136 list_info->
head=next;
1147 list_info->
head=next;
1148 list_info->
tail=next;
1250 if (array == (
void **) NULL)
1253 next=list_info->
head;
1256 array[i]=next->
value;
1307 size_t (*hash)(
const void *),
1309 void *(*relinquish_key)(
void *),
void *(*relinquish_value)(
void *))
1317 (void) memset(hashmap_info,0,
sizeof(*hashmap_info));
1319 if (hash != (
size_t (*)(
const void *)) NULL)
1320 hashmap_info->
hash=hash;
1323 hashmap_info->
compare=compare;
1329 capacity+1UL,
sizeof(*hashmap_info->
map));
1332 (void) memset(hashmap_info->
map,0,(
size_t) capacity*
1333 sizeof(*hashmap_info->
map));
1336 return(hashmap_info);
1370 (void) memset(list_info,0,
sizeof(*list_info));
1371 list_info->
capacity=capacity == 0 ? (size_t) (~0) : capacity;
1412#define MaxCapacities 20
1417 17, 31, 61, 131, 257, 509, 1021, 2053, 4099, 8191, 16381, 32771,
1418 65537, 131071, 262147, 524287, 1048573, 2097143, 4194301, 8388617
1444 if (hashmap_info->
capacity < capacities[i])
1448 capacity=capacities[i+1];
1453 (void) memset(map,0,(
size_t) capacity*
sizeof(*map));
1457 for (i=0; i < (ssize_t) hashmap_info->
capacity; i++)
1462 list_info=hashmap_info->
map[i];
1471 map_info=map[entry->
hash % capacity];
1475 map[entry->
hash % capacity]=map_info;
1477 map_info->
next=element;
1479 map_info->
head=element;
1482 list_info->
signature=(~WizardSignature);
1488 hashmap_info->
map=map;
1494 const void *key,
const void *value)
1508 if ((key == (
void *) NULL) || (value == (
void *) NULL))
1514 next->
hash=hashmap_info->
hash(key);
1515 next->
key=(
void *) key;
1516 next->
value=(
void *) value;
1527 for (i=0; entry != (
EntryInfo *) NULL; i++)
1537 compare=hashmap_info->
compare(key,entry->
key);
1603 if ((list_info->
elements == 0) || (value == NULL))
1604 return((
void *) NULL);
1608 if (list_info->
next == list_info->
head)
1610 next=list_info->
head;
1619 next=list_info->
head;
1626 return((
void *) NULL);
1630 if (element == list_info->
tail)
1631 list_info->
tail=next;
1632 if (list_info->
next == element)
1638 return((
void *) value);
1682 return((
void *) NULL);
1686 if (list_info->
next == list_info->
head)
1689 next=list_info->
head;
1698 next=list_info->
head;
1699 for (i=1; i < (ssize_t) index; i++)
1703 if (element == list_info->
tail)
1704 list_info->
tail=next;
1705 if (list_info->
next == element)
1707 value=element->
value;
1760 return((
void *) NULL);
1762 hash=hashmap_info->
hash(key);
1763 list_info=hashmap_info->
map[hash % hashmap_info->
capacity];
1768 for (i=0; entry != (
EntryInfo *) NULL; i++)
1770 if (entry->
hash == hash)
1778 compare=hashmap_info->
compare(key,entry->
key);
1785 return((
void *) NULL);
1800 return((
void *) NULL);
1834 return((
void *) NULL);
1836 if (list_info->
next == list_info->
tail)
1850 next=list_info->
head;
1851 while (next->
next != list_info->
tail)
1854 list_info->
tail=next;
1890 hashmap_info->
next=0;
#define ThrowWizardFatalError(domain, error)
WizardExport HashInfo * AcquireHashInfo(const HashType hash)
WizardExport WizardBooleanType UpdateHash(HashInfo *hash_info, const StringInfo *message)
WizardExport WizardBooleanType InitializeHash(HashInfo *hash_info)
WizardExport HashInfo * DestroyHashInfo(HashInfo *hash_info)
WizardExport const StringInfo * GetHashDigest(const HashInfo *hash_info)
WizardExport WizardBooleanType FinalizeHash(HashInfo *hash_info)
WizardExport void * RemoveEntryFromHashmap(HashmapInfo *hashmap_info, const void *key)
WizardExport size_t HashStringInfoType(const void *string)
WizardExport void * GetNextValueInHashmap(HashmapInfo *hashmap_info)
WizardExport WizardBooleanType CompareHashmapString(const void *target, const void *source)
static WizardBooleanType IncreaseHashmapCapacity(HashmapInfo *hashmap_info)
WizardExport void * GetLastValueInLinkedList(LinkedListInfo *list_info)
WizardExport void * GetValueFromHashmap(HashmapInfo *hashmap_info, const void *key)
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 void * GetValueFromLinkedList(LinkedListInfo *list_info, const size_t index)
WizardExport void * RemoveLastElementFromLinkedList(LinkedListInfo *list_info)
WizardExport WizardBooleanType IsLinkedListEmpty(const LinkedListInfo *list_info)
WizardExport WizardBooleanType IsHashmapEmpty(const HashmapInfo *hashmap_info)
WizardExport size_t GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
struct _ElementInfo ElementInfo
WizardExport size_t HashStringType(const void *string)
WizardExport WizardBooleanType LinkedListToArray(LinkedListInfo *list_info, void **array)
WizardExport void ClearLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
WizardExport void * GetNextKeyInHashmap(HashmapInfo *hashmap_info)
WizardExport void ResetLinkedListIterator(LinkedListInfo *list_info)
WizardExport size_t GetNumberOfElementsInLinkedList(const LinkedListInfo *list_info)
WizardExport WizardBooleanType InsertValueInSortedLinkedList(LinkedListInfo *list_info, int(*compare)(const void *, const void *), void **replace, const void *value)
WizardExport WizardBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
WizardExport WizardBooleanType CompareHashmapStringInfo(const void *target, const void *source)
WizardExport HashmapInfo * DestroyHashmap(HashmapInfo *hashmap_info)
WizardExport void * RemoveElementFromLinkedList(LinkedListInfo *list_info, const size_t index)
WizardExport size_t HashPointerType(const void *pointer)
struct _EntryInfo EntryInfo
WizardExport WizardBooleanType InsertValueInLinkedList(LinkedListInfo *list_info, const size_t index, const void *value)
WizardExport void * RemoveElementByValueFromLinkedList(LinkedListInfo *list_info, const void *value)
WizardExport void ResetHashmapIterator(HashmapInfo *hashmap_info)
WizardExport LinkedListInfo * NewLinkedList(const size_t capacity)
WizardExport WizardBooleanType PutEntryInHashmap(HashmapInfo *hashmap_info, const void *key, const void *value)
WizardExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
WizardExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
WizardExport void * AcquireWizardMemory(const size_t size)
WizardExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
WizardExport void * RelinquishWizardMemory(void *memory)
WizardExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
WizardExport SemaphoreInfo * AcquireSemaphoreInfo(void)
WizardExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
WizardExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
WizardExport size_t GetStringInfoLength(const StringInfo *string_info)
WizardExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
WizardExport StringInfo * StringToStringInfo(const char *string)
struct _ElementInfo * next
size_t(* hash)(const void *)
void *(* relinquish_key)(void *)
void *(*) *(* relinquish_value)(void *)
WizardBooleanType head_of_list
WizardBooleanType(* compare)(const void *, const void *)
SemaphoreInfo * semaphore
SemaphoreInfo * semaphore