source: trunk/lib/symtab/bitstream_hash_table.h @ 1462

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

SymbolTable?: refactored symtab library

File size: 1.6 KB
Line 
1/*
2 * Created on: 26-August-2011
3 * Author: Vera Lukman
4 *
5 * This hash table is almost an exact copy of HashSymbolTable except that
6 * BitStreamDivHashTable accepts a hashvalue to insert or lookup for a key.
7 * This hash table is designed specifically for Parallel Bitstream-Based Length Sorting Symbol Table.
8 * It is the base class of BitstreamIdentityHashTable, BitstreamLogHashTable and BitstreamDivHashTable.
9 *
10 * Each grouping strategy use different comparison strategy
11 * Identity group sorting        f(L) = L
12 * Log group sorting             f(L) = ceil (log(L))
13 * Division group sorting        f(L) = floor( (L-1)/2^k )
14 *
15 */
16
17#ifndef BITSTREAM_HASH_TABLE_H
18#define BITSTREAM_HASH_TABLE_H
19
20#define DEBUG_BHT 0
21
22#define TABLE_SIZE 256
23#define TABLE_SIZE_MASK TABLE_SIZE-1
24
25class BitStreamHashTable
26{
27
28public:
29    BitStreamHashTable();
30    ~BitStreamHashTable();
31
32    // Symbol length > 16
33    unsigned int Lookup_Name_17(char * name, const int hashvalue, int L);
34
35    void Insert_Name(char * name, const int hashvalue, const unsigned int gid);
36    void Insert_Name(char * name, const int hashvalue, const unsigned int gid, const unsigned int lgth);
37
38    // DEBUG FUNCTIONS
39    void Print_Symbol_Table_Distribution();
40
41protected:
42    struct CHAIN {
43        const char* key;
44        struct CHAIN* next;
45        unsigned int GID;
46        unsigned int lgth;
47    };
48
49    CHAIN ** g_table;
50    inline unsigned int getIndex(const int hashvalue);
51
52private:
53    void free_chain(CHAIN* chain);
54};
55
56inline unsigned int BitStreamHashTable::getIndex(const int hashvalue)
57{
58    return hashvalue & TABLE_SIZE_MASK;
59}
60
61#endif // BITSTREAM_HASH_TABLE_H
Note: See TracBrowser for help on using the repository browser.