Sorry, my fault ...

I thought that a hashmap is well-known as it is a common and one of the most used container in nearly every programming language.

To keep it short:

A hashmap is used to store objects under a unique key in a container and get it back by its key.

For a detailed explanation follow that link:

http://en.wikipedia.org/wiki/Hash_table

As GS doesn't support hashmaps (only a simple type of arrays and some kind of linked lists by using structs), I wrote this dll.

And now a short example how to use my GSHashmap with Lite-C (C-Script should work as well):

Put the GSHashmap.dll into your plugins folder. Usually Lite-C opens DLLs on its own, so you do not have to load it in script. If you have to, just take a look in the GS manual.

Put the file GSHashmap.h into your working directory or whereever you have your header files and add the following line to your main.c:

#include "GSHashmap.h"

That's all you have to do to use the GSHashmap :-)

Now you can use the following functions:

function addToGSHashmap(key,value); // char* key, var value
is used to add a value (for example a pointer or whatever fits in a var)
under a given key into the hashmap:

addToGSHashmap(_chr("myplayer"), ((ENTITY*)player));

function getFromGSHashmap(key);
is used to get the stored values back from the hashmap:

ENTITY* player = (ENTITY*)getFromGSHashmap(_chr("myplayer"));

function clearGSHashmap();
clears all entries from the hashmap.

function removeFromGSHashmap(key);
removes the entry with the given key from the hashmap.

function isInGSHashmap(key); // returns 0 if false, 1 if true
used to check if the entry with the given key exists in the hashmap:

if (isInGSHashmap(_chr("myplayer")) == 1) {
// do something
}

function sizeOfGSHashmap();
returns the current number of entries in the hashmap

***********************************************************************

And here's a short snippet from my project how I use the GSHashmap to store pointers to struct objects filled with data read from a file:

var fhandle;

void filereader() {
fhandle = file_open_read("..\\database\\objects.data");
if (fhandle != 0) {
var tempPointer = 0;
str_cpy(delimit_str,";");
STRING* objName = "";
STRING* str = "";
while (file_str_read(fhandle,objName) != -1) {
USEABLE_OBJECT* tmpObj = (USEABLE_OBJECT*)malloc(sizeof(USEABLE_OBJECT));
file_str_read(fhandle,str);
((USEABLE_OBJECT*)tmpObj).displayName = str_create(str);
file_str_read(fhandle,str);
((USEABLE_OBJECT*)tmpObj).description = str_create(str);
addToGSHashmap(_chr(objName), ((USEABLE_OBJECT*)tmpObj));
file_str_read(fhandle,str);
}
}
file_close(fhandle);
}

***********************************************************************

Hope that helps.

If there are questions ... ask me :-)

Best regards,
Pegamode.