home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************\
- ** **
- ** 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. Windbase Software Inc. **
- ** ALL RIGHTS RESERVED. **
- \*****************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
-
- #include "../memsl.h"
-
- WBDHASH *dhash;
- char strarray[200][21];
- int numexe = 0;
-
- #ifdef WBSTDC
- int Compare(void *nullitem, char *item1, char *item2)
- #else
- int Compare(nullitem, item1, item2)
- void *nullitem;
- char *item1,
- *item2;
- #endif
- {
- WBTrcEntry(0,"Compare",("%p, %s, %s",nullitem,item1?item1:"NULL",item2?item2:"NULL"));
-
- nullitem = nullitem;
-
- WBTrcReturn(0,strcmp(item1,item2),("%d",strcmp(item1,item2)));
- }
-
- #ifdef WBSTDC
- void Execute(void *nullitem, char *item)
- #else
- void Execute(nullitem, item)
- void *nullitem;
- char *item;
- #endif
- {
- WBTrcEntry(0,"Execute",("%p, %s",nullitem,item?item:"NULL"));
-
- nullitem = nullitem;
-
- numexe++;
- printf("%d %s\n",numexe,item);
-
- WBTrcVReturn(0,(""));
- }
-
- #if defined(WBTRC_LEVEL1) || defined(WBTRC_LEVEL2)
- #ifdef WBSTDC
- int main(int argc, char **argv)
- #else
- int main(argc, argv)
- int argc;
- char **argv;
- #endif
- #else
- #ifdef WBSTDC
- int main(void)
- #else
- int main()
- #endif
- #endif
- {
- FILE *file;
- int i = 0, i2;
-
- WBTrcMainEntry();
-
- memset(strarray,0,sizeof(strarray));
-
- if ((dhash = WBDHashOpen(NULL,3)) != NULL)
- {
- WBDHashHashingF(dhash,NULL,WBDHashFunct);
- #ifdef FUNCTCAST
- WBDHashCompareF(dhash,NULL,(int (*)(void *, void *, void *))Compare);
- WBDHashExecuteF(dhash,NULL,(void (*)(void *, void *))Execute);
- #else
- WBDHashCompareF(dhash,NULL,(int (*)())Compare);
- WBDHashExecuteF(dhash,NULL,(void (*)())Execute);
- #endif
-
- if (WBDHashIsEmpty(dhash))
- printf("Hash table is empty.\n");
- else
- printf("Hash table is NOT empty.\n");
-
- if ((file = fopen("data.dat","r")) != NULL)
- {
- while (i < 200 && fgets(strarray[i],20,file))
- {
- if (strarray[i][strlen(strarray[i])-1] == '\n')
- strarray[i][strlen(strarray[i])-1] = 0;
- WBDHashAdd(dhash,strarray[i]);
- i++;
- }
- fclose(file);
-
- printf("Hash table statistics can be found in \"dhash.sta\"\n");
- WBDHashStats(dhash,"dhash.sta");
- if (WBDHashIsEmpty(dhash))
- printf("Hash table is empty.\n");
- else
- printf("Hash table is NOT empty.\n");
-
- printf("Hash Table contains %ld items.\n",WBDHashNumItems(dhash));
-
- WBDHashExecute(dhash);
-
- for (i2 = 0; i2 < i; i2++)
- {
- if (WBDHashSearch(dhash,strarray[i2]))
- printf("WBDHashSearch(): Found %s\n",strarray[i2]);
- else
- printf("WBDHashSearch(): %s was not found\n",strarray[i2]);
- }
- printf("i2 = %d\n",i2);
-
- /*
- ** No deletion function is defined, so the items
- ** will not be freed. Only the cells holding
- ** the items will be freed.
- */
- for (i2 = 0; i2 < i; i2++)
- {
- if (WBDHashDelete(dhash,strarray[i2]))
- printf("WBDHashDelete(): Deleted %s\n",strarray[i2]);
- else
- printf("WBDHashDelete(): %s was not found\n",strarray[i2]);
- }
- printf("i2 = %d\n",i2);
- }
- WBDHashClose(dhash);
- }
- WBTrcReturn(0,0,("0"));
- }
-