Stardew Engine
Loading...
Searching...
No Matches
StringKeyHashMap.c File Reference
#include "StringKeyHashMap.h"
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include "AssertLib.h"
#include "Log.h"
Include dependency graph for StringKeyHashMap.c:

Data Structures

struct  KVP
 

Macros

#define STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR   0.75f
 

Functions

unsigned int djb2 (char *str)
 
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 * 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 KVPHashmapSearchKVP (struct HashMap *pMap, char *key)
 
struct KVPInsertKVPIntoNewAlloc (struct HashMap *pMap, struct KVP *pKVPsrc, char *pNewAlloc)
 insert from the old allocation to the new
 
void HashmapPrintEntries (struct HashMap *pMap, const char *hashMapName)
 
void HashmapResize (struct HashMap *pMap)
 
void * HashmapInsert (struct HashMap *pMap, char *key, void *pVal)
 
struct KVPFindMoveableKey (struct KVP *pHole, struct HashMap *pMap)
 
bool HashmapDeleteItem (struct HashMap *pMap, char *key)
 
struct HashmapKeyIterator GetKeyIterator (struct HashMap *pHashMap)
 Get an iterator object that you can call "NextHashmapKey" with to iterate through the hashmaps keys.
 
char * NextHashmapKey (struct HashmapKeyIterator *itr)
 
void HashmapDeInit (struct HashMap *pMap)
 

Macro Definition Documentation

◆ STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR

#define STARDEW_HASHMAP_DEFAULT_LOAD_FACTOR   0.75f

Function Documentation

◆ djb2()

unsigned int djb2 ( char *  str)

◆ FindMoveableKey()

struct KVP * FindMoveableKey ( struct KVP pHole,
struct HashMap pMap 
)

◆ GetKeyIterator()

struct HashmapKeyIterator GetKeyIterator ( struct HashMap pHashMap)

Get an iterator object that you can call "NextHashmapKey" with to iterate through the hashmaps keys.

◆ HashmapDeInit()

void HashmapDeInit ( struct HashMap pMap)
Parameters
pMap

◆ HashmapDeleteItem()

bool HashmapDeleteItem ( struct HashMap pMap,
char *  key 
)
Parameters
pMap
key
Returns

◆ HashmapInit()

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

Parameters
pMap
capacity
valSizesize of individual values

◆ HashmapInitWithLoadFactor()

void HashmapInitWithLoadFactor ( struct HashMap pMap,
int  capacity,
int  valSize,
float  loadFactor 
)

same as HashmapInit but sets load factor as well

Parameters
pMap
capacity
valSize
loadFactorsize of individual values

◆ HashmapInsert()

void * HashmapInsert ( struct HashMap pMap,
char *  key,
void *  pVal 
)
Parameters
pMap
key
pVal
Returns
true if a new key and inserted, false if an existing key and value overwritten

◆ HashmapPrintEntries()

void HashmapPrintEntries ( struct HashMap pMap,
const char *  hashMapName 
)
Parameters
pMap
hashMapName

◆ HashmapResize()

void HashmapResize ( struct HashMap pMap)

◆ HashmapSearch()

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.

Parameters
pMap
key
Returns

◆ HashmapSearchKVP()

struct KVP * HashmapSearchKVP ( struct HashMap pMap,
char *  key 
)

◆ InsertKVPIntoNewAlloc()

struct KVP * InsertKVPIntoNewAlloc ( struct HashMap pMap,
struct KVP pKVPsrc,
char *  pNewAlloc 
)

insert from the old allocation to the new

Parameters
pMap
pKVPsrckvp from old allocation
pNewAllocNew allocation
Returns
The KVP inserted into pNewAlloc

◆ NextHashmapKey()

char * NextHashmapKey ( struct HashmapKeyIterator itr)
Parameters
<br>
Returns