source: trunk/lib/symtab/hash_symbol_table.h @ 1518

Last change on this file since 1518 was 1229, checked in by vla24, 8 years ago

Reorganized SymbolTable? library

File size: 2.0 KB
Line 
1#ifndef HASH_SYMBOL_TABLE_H
2#define HASH_SYMBOL_TABLE_H
3
4//#define USE_PRIME
5#define USE_CHAINING
6//#define STORE_32
7#define _CRT_SECURE_NO_DEPRECATE
8
9
10#include <stdlib.h>
11#include "stringpool.h"
12#include <string.h>
13#include <vector>
14
15using namespace std;
16
17struct Name_Data;
18
19class HashSymbolTable
20{
21
22#ifdef USE_CHAINING
23    struct CHAIN;
24    struct CHAIN {
25            const char* key;
26            struct CHAIN* next;
27            unsigned int GID;
28    };
29    typedef struct CHAIN CHAIN;
30#else
31    typedef struct {
32            const char* key;
33    #ifdef STORE_32
34            UINT hash32;
35    #endif
36            unsigned int GID;
37    } ITEM;
38#endif
39
40public:
41    /*
42    enum HashFuncEnum
43    {
44        HashBernstein,
45        HashKernighanRitchie,
46        Hash17_unrolled,
47        Hash65599,
48        HashFNV1a,
49        HashUniversal,
50        HashWeinberger,
51        HashLarson,
52        HashPaulHsieh,
53        HashOneAtTime,
54        HashLookup3,
55        HashArashPartow,
56        CRC32,
57        HashRamakrishna,
58        HashFletcher,
59        HashMurmur2,
60        HashHanson,
61        NovakHashUnrolled,
62        HashSBox,
63        HashMaPrime2c,
64        Hash_Jesteress,
65        Hash_Meiyan,
66        HashMurmur2A,
67    #ifdef _WIN64
68        HashAlfalfa_QWORD,
69        HashFNV1A_unrolled8
70    #endif
71    //    HashFNV1A_unrolled,
72    //    HashAlfalfa,
73    //    HashAlfalfa_HALF,
74    //    HashAlfalfa_DWORD,
75    //    Hash_Sixtinsensitive,
76    //    Hash_WHIZ,
77    };
78*/
79    HashSymbolTable();
80    ~HashSymbolTable();
81
82    // Returns hash value
83    // Returns -1 upon failure
84    unsigned int Lookup_or_Insert_Name(char * name, int lgth);
85
86//    char * Get_Name(int nameID);
87//    int Get_Lgth(int nameID);
88
89    vector<Name_Data> NameTable;
90
91private:
92    size_t g_lines_count;
93    size_t g_table_size_mask;
94    size_t g_table_size;
95
96    StringPool<4096,100> pool;
97
98    unsigned int m_globalNameCount;
99
100#ifdef USE_CHAINING
101    CHAIN ** g_table;
102    CHAIN * g_chains;
103    unsigned int g_next_free_chain;
104#else
105    ITEM * g_table;
106#endif
107
108    void AllocateHashTable();
109    void InitHashTable();
110    void SetTableSize(unsigned int table_bits, unsigned int table_bits_factor);
111    void FreeHashTable();
112
113};
114
115#endif // HASH_SYMBOL_TABLE_H
Note: See TracBrowser for help on using the repository browser.