Page 1 of 1

Hash Implementation

PostPosted: Tue Jul 03, 2012 6:09 pm
by skydereign
Here is a small example of a hashed array data structure in gE. It uses linked lists for collision resolution (so there is a linked list implemented as well). I haven't fully tested it in gE, though I've been using it outside of gE. So you might find some problems. Not all of the hash functions are implemented, currently there is no hash_print, and hash_traverse doesn't work. But, it does get the general idea of a hash across.

There are some more advanced topics used in this, such as function pointers, so if anyone wants something explained just ask. I'll update this as I get more time. But for now, all the game logic does is allow you to add to and search the array. The actor with the text word to add is the text input actor. When you press enter it will try to add the name to the array. Pressing control-s will search the array for the text, and display a found message if it was found. In future I'll come up with a more interesting example.

Re: Hash Implementation

PostPosted: Thu Jul 05, 2012 8:40 pm
by AliceXIII
hmm.. i understand what your getting at it's interesting if you don't mind i might use it in my template engine? ;)

im thinking i could add it into my map editor that would allow you to create the lists for npcs, and other assorted things while in the map editor well it's not necessarily just a map editor as you can pinpoint npcs and enemies positions on the map. but anyways then possibly use it to be able to search through the array to pick specific npcs or enemies to make it easier to use the editor :D

Re: Hash Implementation

PostPosted: Fri Jul 06, 2012 7:41 am
by skydereign
Go ahead. I posted this as an example and template for anyone who might need it. Hashing can be quite convenient. I haven't written a function to read and write it out though, which would be pretty handy. But, as I'm finishing up a general case serializing function, that isn't currently very high on my todo list.

Re: Hash Implementation

PostPosted: Fri Jul 06, 2012 12:44 pm
by AliceXIII
well i've been messing around with reading and writing array maps so i could when i get the time after my visit to the SSA office
which will take awhile look into patching it up..

my editor and gameplay template could use something like this definetly i just never thought about implementing one myself i've read all about stuff like this though in my book(i found these 2 nifty books for 1$ each at my local goodwill a year ago 1's a very good primer to understanding C and the other is all about simple to advanced data structures in C++ which most of it is more advanced structures which is nice for me) so i understand a little of whats going on as i haven't read through all your code just kinda skimmed real fast :p

but for now i have a busy day ahead of myself at the SSA well unless i mail my form into them lol