Hash Implementation
Posted: Tue Jul 03, 2012 6:09 pm
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.
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.