well, I'm not sure about what you know, but hashing (as far as I know) is a method for extremely-fast searching, and it consists of giving each input value a unique number, based on the contents of the object you want to store, when you get this number, you associate it with a list, and store it in the index that corresponds to the number you got, the best idea for doing this is using pointers. Each time the user enters a new value, the program must:
-find the number associated with the object
-append the object (or a description of it, anything which can help you to determine whether the value the user searched matches or not the value stored in the table) at the end (or at the beggining) of the hash queue
-Do any other cleanups you must do (such as upgrading the number-of-values counter.
So, when the user searches for a precise value, you must find the number which is associated with your object, look up the index in your hash table, and start searching linearilly (one by one) in that index, and checking if the object which was searched matches the one you're checking.
it would be something like this (in C++):
the problem with doing hash tables is that modifying or erasing values is a little boring, but it can also be done.
int amount; //In this array, we're going to store the amount of objects appended to
//any index of our hash table
char text; //We're going to do strings
objects* next; //The pointer to the next structure
objects object; //this is the maximum amount of objects
int g; //The amount of objects stored
return 0; //We want to do ANSI, don't we? :)
int GetNumber(char* s)
This is just a suggestion of what kind of encoding
you could use, but you're free to use any kind of encoding
return n%100; //The maximum index possible is 99, so, if the value is greater
//than 99, we should cut it to fit our hash table.
int AddObject(char* s) //The new string
strcpy(object[g]->text,s); //We suppose that is is up to 99 characters long
//We're going to do a little trick in here: open the chain at the beggining and place
//our object in the middle
//OK!, now our object is on the right place.
g++; //Update our counters
return 0; //For an ANSI compliant program
int LookupObject(char* s) //The string we're searching for
o=hash[n].next; //We're only going to check the objects whose value corresponds to the value of our search
for(int i=0;i<amount[n];i++) //I'm not sure if it's < or <=
return 1; //FOUND!!!
o=o->next; //Go to the next value in our hash table
return 0; //Search string not found!
I hope that you understand this, if you don't, please, don't hesitate to tell me!
whoof, this is a new record for me!!! 3272 characters long!