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

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

SymbolTable?: hash table implementation for paralel bitstream based length sorting (PBGS) now auto-resizes. Fixed flipBit function used by Div2 grouping strategy

File size: 1.4 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
8 * identity grouping strategy.
9 *
10 * Identity group sorting        f(L) = L
11 */
12
13#ifndef BITSTREAM_ID_HASH_TABLE_H
14#define BITSTREAM_ID_HASH_TABLE_H
15#define USE_IDENTITY_SORT
16
17#include "bitstream_hash_table.h"
18#include "pbgs_utilities.h"
19
20class BitStreamIdentityHashTable : public BitStreamHashTable
21{
22public:
23
24    //Returns 0 upon failure
25    // Symbol length [1,16]
26    template <int L> inline unsigned int Lookup_Name(char * name, const int hashvalue);
27};
28
29template <int L>
30        unsigned int BitStreamIdentityHashTable::Lookup_Name(char * name, const int hashvalue)
31{
32    unsigned int bucket = getBucket(hashvalue, g_tableSize);
33
34    // Look up the value in the chain
35    for(CHAIN* chain = g_table[bucket]; chain != NULL; chain = chain->next) {
36#if DEBUG_BHT
37        printf ("Check symbol: %s\n", chain->key);
38#endif
39        if( id_equal_compare <L> ((unsigned char*)chain->key, (unsigned char*)name) )
40        {
41#if DEBUG_BHT
42            printf ("Found GID: %i\n", chain->GID);
43#endif
44            return chain->GID;
45        }
46    }
47
48#if DEBUG_BHT
49    printf ("Not Found GID: %i\n", 0);
50#endif
51
52    return 0;
53}
54#endif // BITSTREAM_ID_HASH_TABLE_H
Note: See TracBrowser for help on using the repository browser.