File StringKeyHashMap.c
FileList > core > StringKeyHashMap.c
Go to the source code of this file
#include "StringKeyHashMap.h"#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <stdio.h>#include "AssertLib.h"#include "Log.h"
Classes
| Type | Name |
|---|---|
| struct | KVP |
Public Functions
| Type | Name |
|---|---|
| struct KVP * | FindMoveableKey (struct KVP * pHole, struct HashMap * pMap) |
| struct HashmapKeyIterator | GetKeyIterator (struct HashMap * pHashMap) Get an iterator object that you can call "NextHashmapKey" with to iterate through the hashmaps keys. |
| void | HashmapDeInit (struct HashMap * pMap) |
| bool | HashmapDeleteItem (struct HashMap * pMap, char * key) |
| void | HashmapInit (struct HashMap * pMap, int capacity, int valSize) initializes the hashmap struct to a decfault value. you can change fLoadFactor afterwards but it sets it to a default value |
| void | HashmapInitWithLoadFactor (struct HashMap * pMap, int capacity, int valSize, float loadFactor) same as HashmapInit but sets load factor as well |
| void * | HashmapInsert (struct HashMap * pMap, char * key, void * pVal) |
| void | HashmapPrintEntries (struct HashMap * pMap, const char * hashMapName) |
| void | HashmapResize (struct HashMap * pMap) |
| void * | HashmapSearch (struct HashMap * pMap, char * key) Search for a key in the hash map, returns a pointer to the value or NULL if not present. |
| struct KVP * | HashmapSearchKVP (struct HashMap * pMap, char * key) |
| struct KVP * | InsertKVPIntoNewAlloc (struct HashMap * pMap, struct KVP * pKVPsrc, char * pNewAlloc) insert from the old allocation to the new |
| char * | NextHashmapKey (struct HashmapKeyIterator * itr) |
| unsigned int | djb2 (char * str) |
Public Static Functions
| Type | Name |
|---|---|
| struct KVP * | BucketAtIndex (struct HashMap * pMap, int i) |
| int | GetIndex (struct HashMap * pMap, struct KVP * pKVP) |
| void | HashmapInitBase (struct HashMap * pMap, int capacity, int valSize) |
| void * | HashmapSearchBase (struct HashMap * pMap, char * key, bool bReturnVal) |
| int | NextIndex (struct HashMap * pMap, int i) |
Macros
| Type | Name |
|---|---|
| define | STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR 0.75f |
Public Functions Documentation
function FindMoveableKey
struct KVP * FindMoveableKey (
struct KVP * pHole,
struct HashMap * pMap
)
function GetKeyIterator
Get an iterator object that you can call "NextHashmapKey" with to iterate through the hashmaps keys.
struct HashmapKeyIterator GetKeyIterator (
struct HashMap * pHashMap
)
function HashmapDeInit
void HashmapDeInit (
struct HashMap * pMap
)
Parameters:
pMap
function HashmapDeleteItem
bool HashmapDeleteItem (
struct HashMap * pMap,
char * key
)
Parameters:
pMapkey
Returns:
function HashmapInit
initializes the hashmap struct to a decfault value. you can change fLoadFactor afterwards but it sets it to a default value
void HashmapInit (
struct HashMap * pMap,
int capacity,
int valSize
)
Parameters:
pMapcapacityvalSizesize of individual values
function HashmapInitWithLoadFactor
same as HashmapInit but sets load factor as well
void HashmapInitWithLoadFactor (
struct HashMap * pMap,
int capacity,
int valSize,
float loadFactor
)
Parameters:
pMapcapacityvalSizeloadFactorsize of individual values
function HashmapInsert
void * HashmapInsert (
struct HashMap * pMap,
char * key,
void * pVal
)
Parameters:
pMapkeypVal
Returns:
true if a new key and inserted, false if an existing key and value overwritten
function HashmapPrintEntries
void HashmapPrintEntries (
struct HashMap * pMap,
const char * hashMapName
)
Parameters:
pMaphashMapName
function HashmapResize
void HashmapResize (
struct HashMap * pMap
)
function HashmapSearch
Search for a key in the hash map, returns a pointer to the value or NULL if not present.
void * HashmapSearch (
struct HashMap * pMap,
char * key
)
Parameters:
pMapkey
Returns:
function HashmapSearchKVP
struct KVP * HashmapSearchKVP (
struct HashMap * pMap,
char * key
)
function InsertKVPIntoNewAlloc
insert from the old allocation to the new
struct KVP * InsertKVPIntoNewAlloc (
struct HashMap * pMap,
struct KVP * pKVPsrc,
char * pNewAlloc
)
Parameters:
pMappKVPsrckvp from old allocationpNewAllocNew allocation
Returns:
The KVP inserted into pNewAlloc
function NextHashmapKey
char * NextHashmapKey (
struct HashmapKeyIterator * itr
)
Parameters:
<br>
Returns:
function djb2
unsigned int djb2 (
char * str
)
Public Static Functions Documentation
function BucketAtIndex
static struct KVP * BucketAtIndex (
struct HashMap * pMap,
int i
)
function GetIndex
static int GetIndex (
struct HashMap * pMap,
struct KVP * pKVP
)
function HashmapInitBase
static void HashmapInitBase (
struct HashMap * pMap,
int capacity,
int valSize
)
function HashmapSearchBase
static void * HashmapSearchBase (
struct HashMap * pMap,
char * key,
bool bReturnVal
)
Parameters:
pMapkeybReturnValif true, return the value, if false, return the KVP struct
Returns:
function NextIndex
static int NextIndex (
struct HashMap * pMap,
int i
)
Macro Definition Documentation
define STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR
#define STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR `0.75f`
The documentation for this class was generated from the following file /home/runner/work/2DFarmingRPG/2DFarmingRPG/Stardew/engine/src/core/StringKeyHashMap.c