All pastes #507831 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2007-05-24 19:26 UTC
rendered paste body
int table::adtHashFunction(const int hashsize, char * cpKey){           table t;    adtHashPosition = 0;    int len = strlen(cpKey)+1;    char cpKeyArray[len];    char adtHashTable[hashsize+1][len+1];        for(int i = 0; *adtHashTable[i]; i++)    {        adtHashTable[i][0] = '\0';    }        for(int i = 0; i < strlen(cpKey); i++)    {        //add each letter of the clients key for the hash position        adtHashPosition = adtHashPosition + cpKey[i];    }    //mod hash position by 1009 to get a constrained number    adtHashPosition = adtHashPosition % hashsize;        if(adtHashTable[adtHashPosition][0] == '\0')    {        cout << adtHashTable[adtHashPosition-1] << endl;        //cout << adtHashPosition << endl;        strcpy(adtHashTable[adtHashPosition],cpKey);        cout << adtHashTable[adtHashPosition] << endl;    }        else    {        //LINKED LIST STUFF HERE!        cout << adtHashTable[adtHashPosition-1] << endl;        cout << adtHashPosition << endl;        cout << "ERRRRROOOOOORRRRR! STUFFS HUR!" << endl;    }    return 1;}