home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ User's Journal & Wi…eveloper's Journal Tools
/
C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso
/
windbase
/
memslcpp.3
/
dhash1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-11
|
14KB
|
333 lines
/***************************************************************************\
** **
** WW WW IIIIIIII NNN NN DDDDDDD BBBBBBB AA SSSSSS EEEEEEEE **
** WW W WW II NNNN NN DD DD BB BB AA AA SS EE **
** WW W WW II NN NN NN DD DD BBBBBBB AAAAAAAA SSSSSS EEEEEE **
** WW W WW II NN NNNN DD DD BB BB AA AA SS EE **
** WWWWW IIIIIIII NN NNN DDDDDDD BBBBBBB AA AA SSSSSS EEEEEEEE **
** **
** SSSSSS OOOOOO FFFFFFFF TTTTTTTT WW WW AA RRRRRRR EEEEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSS OO OO FFFFF TT WW W WW AAAAAAAA RRRRRRR EEEEEE **
** SS OO OO FF TT WW W WW AA AA RR RR EE **
** SSSSSS OOOOOO FF TT WWWWW AA AA RR RR EEEEEEEE **
** **
********** NOTICE ***********************************************************
** This file contains valuable trade secrets and proprietary **
** assets of Windbase Software Inc. Embodying substantial **
** creative efforts and confidential information. Unauthorized **
** use, copying, decompiling, translating, disclosure or **
** transfer, of any kind, is strictly prohibited. **
** **
** COPYRIGHT (C) 1992, 1993, 1994, 1995. Windbase Software Inc. **
** ALL RIGHTS RESERVED. **
\***************************************************************************/
/*
** Hashing Table with Dynamic Paging and Seperate Chaining
** Templates Version
*/
template <class USRDEF>
class MyDHash : public WBDHash<USRDEF>
{
unsigned int WBHashingFunct(void *nullitem, char *item);
void WBExecuteFunct(void *nullitem, char *item)
{
nullitem = nullitem;
cout << "Execute: " << item << "\n";
}
int WBCompareFunct(void *nullitem, char *item1, char *item2)
{
nullitem = nullitem;
return(strcmp(item1,item2));
}
public:
MyDHash(int avgitems) : WBDHash<USRDEF>(avgitems) {}
};
template <class USRDEF>
unsigned int MyDHash<USRDEF>::WBHashingFunct(void *nullitem, char *item)
{
unsigned int i, val = 0;
nullitem = nullitem;
for (i = 0; i < strlen(item); i++)
val += item[i];
return(val);
}
main()
{
MyDHash<char *> hash(5);
int i;
for (i = 0; i < 20; i++)
{
hash += "Test0";
hash += "Test1";
hash += "Test2";
hash += "Test3";
hash += "Test4";
hash += "Test5";
hash += "Test6";
hash += "Test7";
hash += "Test8";
hash += "Test9";
hash.Add("Test10");
hash.Add("Test11");
hash.Add("Test12");
hash.Add("Test13");
hash.Add("Test14");
hash.Add("Test15");
hash.Add("Test16");
hash.Add("Test17");
hash.Add("Test18");
hash.Add("Test19");
hash.Add("Test20");
hash.Add("Test21");
hash.Add("Test22");
hash.Add("Test23");
hash.Add("Test24");
hash.Add("Test25");
hash.Add("Test26");
hash.Add("Test27");
hash.Add("Test28");
hash.Add("Test29");
hash.Add("Test30");
hash.Add("Test31");
hash.Add("Test32");
hash.Add("Test33");
hash.Add("Test34");
hash.Add("Test35");
hash.Add("Test36");
hash.Add("Test37");
hash.Add("Test38");
hash.Add("Test39");
hash.Add("Test40");
hash.Add("Test41");
hash.Add("Test42");
hash.Add("Test43");
hash.Add("Test44");
hash.Add("Test45");
hash.Add("Test46");
hash.Add("Test47");
hash.Add("Test48");
hash.Add("Test49");
hash.Add("Test50");
hash.Add("Test51");
hash.Add("Test52");
hash.Add("Test53");
hash.Add("Test54");
hash.Add("Test55");
hash.Add("Test56");
hash.Add("Test57");
hash.Add("Test58");
hash.Add("Test59");
hash.Add("Test60");
hash.Add("Test61");
hash.Add("Test62");
hash.Add("Test63");
hash.Add("Test64");
hash.Add("Test65");
hash.Add("Test66");
hash.Add("Test67");
hash.Add("Test68");
hash.Add("Test69");
hash.Add("Test70");
hash.Add("Test71");
hash.Add("Test72");
hash.Add("Test73");
hash.Add("Test74");
hash.Add("Test75");
hash.Add("Test76");
hash.Add("Test77");
hash.Add("Test78");
hash.Add("Test79");
hash.Add("Test4");
hash.Add("Test1");
hash.Add("Test2");
hash.Add("Test3");
hash.Execute();
cout << "Num Items: " << hash.NumItems() << "\n";
cout << "Search: " << hash.Search("Test0") << "\n";
cout << "Search: " << hash.Search("Test1") << "\n";
cout << "Search: " << hash.Search("Test2") << "\n";
cout << "Search: " << hash.Search("Test3") << "\n";
cout << "Search: " << hash.Search("Test4") << "\n";
cout << "Search: " << hash.Search("Test5") << "\n";
cout << "Search: " << hash.Search("Test6") << "\n";
cout << "Search: " << hash.Search("Test7") << "\n";
cout << "Search: " << hash.Search("Test8") << "\n";
cout << "Search: " << hash.Search("Test9") << "\n";
cout << "Search: " << hash.Search("Test10") << "\n";
cout << "Search: " << hash.Search("Test11") << "\n";
cout << "Search: " << hash.Search("Test12") << "\n";
cout << "Search: " << hash.Search("Test13") << "\n";
cout << "Search: " << hash.Search("Test14") << "\n";
cout << "Search: " << hash.Search("Test15") << "\n";
cout << "Search: " << hash.Search("Test16") << "\n";
cout << "Search: " << hash.Search("Test17") << "\n";
cout << "Search: " << hash.Search("Test18") << "\n";
cout << "Search: " << hash.Search("Test19") << "\n";
cout << "Search: " << hash.Search("Test20") << "\n";
cout << "Search: " << hash.Search("Test21") << "\n";
cout << "Search: " << hash.Search("Test22") << "\n";
cout << "Search: " << hash.Search("Test23") << "\n";
cout << "Search: " << hash.Search("Test24") << "\n";
cout << "Search: " << hash.Search("Test25") << "\n";
cout << "Search: " << hash.Search("Test26") << "\n";
cout << "Search: " << hash.Search("Test27") << "\n";
cout << "Search: " << hash.Search("Test28") << "\n";
cout << "Search: " << hash.Search("Test29") << "\n";
cout << "Search: " << hash.Search("Test30") << "\n";
cout << "Search: " << hash.Search("Test31") << "\n";
cout << "Search: " << hash.Search("Test32") << "\n";
cout << "Search: " << hash.Search("Test33") << "\n";
cout << "Search: " << hash.Search("Test34") << "\n";
cout << "Search: " << hash.Search("Test35") << "\n";
cout << "Search: " << hash.Search("Test36") << "\n";
cout << "Search: " << hash.Search("Test37") << "\n";
cout << "Search: " << hash.Search("Test38") << "\n";
cout << "Search: " << hash.Search("Test39") << "\n";
cout << "Search: " << hash.Search("Test40") << "\n";
cout << "Search: " << hash.Search("Test41") << "\n";
cout << "Search: " << hash.Search("Test42") << "\n";
cout << "Search: " << hash.Search("Test43") << "\n";
cout << "Search: " << hash.Search("Test44") << "\n";
cout << "Search: " << hash.Search("Test45") << "\n";
cout << "Search: " << hash.Search("Test46") << "\n";
cout << "Search: " << hash.Search("Test47") << "\n";
cout << "Search: " << hash.Search("Test48") << "\n";
cout << "Search: " << hash.Search("Test49") << "\n";
cout << "Search: " << hash.Search("Test50") << "\n";
cout << "Search: " << hash.Search("Test51") << "\n";
cout << "Search: " << hash.Search("Test52") << "\n";
cout << "Search: " << hash.Search("Test53") << "\n";
cout << "Search: " << hash.Search("Test54") << "\n";
cout << "Search: " << hash.Search("Test55") << "\n";
cout << "Search: " << hash.Search("Test56") << "\n";
cout << "Search: " << hash.Search("Test57") << "\n";
cout << "Search: " << hash.Search("Test58") << "\n";
cout << "Search: " << hash.Search("Test59") << "\n";
cout << "Search: " << hash.Search("T