All pastes #507815 Raw Edit

ashen

public cpp v1 · immutable
·published 2007-05-24 19:16 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] = 0x0;    }        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 % 1009;        if(!adtHashTable[adtHashPosition])    {        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;}