| Line | |
|---|
| 1 |
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright © 2001 Novell, Inc. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 6 | * License or the Artistic License, as specified in the README file.
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | /*
|
|---|
| 11 | * FILENAME : nwhashcls.h
|
|---|
| 12 | * DESCRIPTION : Equivalent of Hash class
|
|---|
| 13 | *
|
|---|
| 14 | * Author : Srivathsa M
|
|---|
| 15 | * Date Created : July 26 2001
|
|---|
| 16 | */
|
|---|
| 17 | #include <stdio.h>
|
|---|
| 18 | #include <conio.h>
|
|---|
| 19 | #include <process.h>
|
|---|
| 20 |
|
|---|
| 21 | #define BUCKET_SIZE 37
|
|---|
| 22 |
|
|---|
| 23 | struct HASHNODE
|
|---|
| 24 | {
|
|---|
| 25 | void *data;
|
|---|
| 26 | struct HASHNODE *next;
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | typedef void (*HASHFORALLFUN)(void *, void *);
|
|---|
| 30 |
|
|---|
| 31 | class NWPerlHashList
|
|---|
| 32 | {
|
|---|
| 33 | private:
|
|---|
| 34 | HASHNODE* MemListHash[BUCKET_SIZE];
|
|---|
| 35 | void removeAll() const;
|
|---|
| 36 |
|
|---|
| 37 | public:
|
|---|
| 38 | ~NWPerlHashList();
|
|---|
| 39 | NWPerlHashList();
|
|---|
| 40 | int insert(void *lData);
|
|---|
| 41 | int remove(void *lData);
|
|---|
| 42 | void forAll( void (*)(void *, void*), void * ) const;
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | struct KEYHASHNODE
|
|---|
| 46 | {
|
|---|
| 47 | void *key;
|
|---|
| 48 | void *data;
|
|---|
| 49 | KEYHASHNODE *next;
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | /**
|
|---|
| 53 | typedef void (*KEYHASHFORALLFUN)(void *, void *);
|
|---|
| 54 |
|
|---|
| 55 | class NWPerlKeyHashList
|
|---|
| 56 | {
|
|---|
| 57 | private:
|
|---|
| 58 | KEYHASHNODE* MemListHash[BUCKET_SIZE];
|
|---|
| 59 | void removeAll() const;
|
|---|
| 60 |
|
|---|
| 61 | public:
|
|---|
| 62 | ~NWPerlKeyHashList();
|
|---|
| 63 | NWPerlKeyHashList();
|
|---|
| 64 | int insert(void *key, void *lData);
|
|---|
| 65 | int remove(void *key);
|
|---|
| 66 | void forAll( void (*)(void *, void*), void * ) const;
|
|---|
| 67 | int find(void *key, void **pData);
|
|---|
| 68 | };
|
|---|
| 69 | **/
|
|---|
| 70 |
|
|---|
| 71 | //#define DEBUG_HASH 1
|
|---|
| 72 |
|
|---|
| 73 | #ifdef DEBUG_HASH
|
|---|
| 74 | #define DEBUGPRINT ConsolePrintf
|
|---|
| 75 | #else
|
|---|
| 76 | #define DEBUGPRINT
|
|---|
| 77 | #endif
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.