// hash.cpp #include "hash.h" //=========================================================================== HashItem::HashItem(char *s, int v) { if (strlen(s) > STR_LEN) { cout< STR_LEN) { cout< &h_array, int &num_items) { num_items = 0; HashItemInt h_item; for (int i = 0; i < data.Size(); i++) { if (!data[i].Empty()) { // now iterate through the linked list int start = 1; while (data[i].GetNext(h_item, start)) { h_array[num_items].Set(h_item.key, h_item.value); start = 0; num_items++; } } } } //=========================================================================== int HashTableInt::ExtToInt(int key, int next_value) { HashItemInt h_item(key, 0); // Check to see if we know this one. 0 matches any number. If we // do know this one, h_item.value gets set to what we knew it to be. if (!Retrieve(h_item)) { h_item.Set(key, next_value); Insert(h_item); } return (h_item.value); } /* // to test out the hash table #include #include #include #define MAX_SYS_CALLS 255 //============================================================================ int GetCalls(HashTable &ht) { ifstream calls_file("calls.txt"); char buff[255]; int buff_len; int num_sys_calls = 0; HashItem h_item; while (!calls_file.eof() && num_sys_calls < MAX_SYS_CALLS) { calls_file.getline(buff, 254); buff_len = strlen(buff); if (buff_len) { // cat on a parenth to make sure only calls are matched strcat(buff, "("); #ifdef DBG cout<