Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c++ simple hashing function help

Status
Not open for further replies.

mkosloff

Programmer
Feb 20, 2003
12
0
0
US
does anyone have the c++ code for a simple hashing function with a modulo? i am trying to figure out how to read numbers from a data file and hash them into specific locations using a simple modulo function, any help would be greatly appreciated.
 
This one is from a sample by... Marc Weiss, I think.

Code:
int hash( int key, int tableSize )
        {
            if( key < 0 ) key = -key;
            return key % tableSize;
        }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top