Ignore:
Timestamp:
Aug 26, 2011, 3:33:01 PM (8 years ago)
Author:
vla24
Message:

Symbol Table: Refactored code. Split HashTable? implementation into 3 classes according to grouping strategies.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/symtab/pbgs_identity_symbol_table.h

    r1387 r1391  
    66 * Identity grouping strategy.
    77 *
     8 * Identity group sorting        f(L) = L
     9 *
    810 */
    911
     
    1315#define DEBUG_PBGS 0
    1416
    15 // Define either one of grouping functions
    16 #define USE_IDENTITY_SORT       // f(L) = L
    17 //#define USE_LOG_SORT          // f(L) = ceil (log(L))
    18 //#define USE_DIV_SORT          // f(L) = floor( (L-1)/2^k )
    19 
    2017#define TOTAL_GROUPS 18
    2118#define LAST_GROUP TOTAL_GROUPS-1
     
    2320#define USE_FUNCTION_TEMPLATES
    2421#include "stringpool.h"
    25 #include "bitstream_hash_table.h"
     22#include "bitstream_id_hash_table.h"
    2623#include "ls_symbol_table_compare.h"
    2724#include "ls_symbol_table_util.h"
     
    4239    template <int L> inline int Lookup_or_Insert_Name(char* name, int hashvalue);
    4340
    44     // Use this function for 17 <= L <= 32
    45     inline int Lookup_or_Insert_Name_32(char* name, int hashvalue, int L);
    46 
    47     // Use this function for L > 32
     41    // Use this function for L > 16
    4842    inline int Lookup_or_Insert_Name(char* name, int hashvalue, int L);
    4943
     
    5246private:
    5347    StringPool <4096,100> m_pool;
    54     BitStreamHashTable m_hashTable[TOTAL_GROUPS];
     48    BitStreamIdentityHashTable m_hashTable[TOTAL_GROUPS];
    5549
    5650    inline int getHashTableIndex(int L);
     
    206200}
    207201
    208 // Use this function for 17 <= L <= 32
    209 inline int PBGSIdentitySymbolTable::Lookup_or_Insert_Name_32(char* name, int hashvalue, int L)
    210 {
    211     int GID = 0;
    212 
    213     //Lookup
    214     GID = m_hashTable[LAST_GROUP].Lookup_Name_32(name, hashvalue, L);
    215 
    216     //Insert
    217     if (!GID) //symbol not found
    218     {
    219         char* c = m_pool.Insert(name, L);
    220         GID = m_globalNameCount;
    221 
    222         m_hashTable[LAST_GROUP].Insert_Name(c, hashvalue, m_globalNameCount, L);
    223         m_globalNameCount++;
    224     }
    225 #if DEBUG_PBGS
    226     char delim = name[L];
    227     name[L] = '\0';
    228     cout << "Lookup or Insert: " << name << " | lgth: " << L << " | group: " << LAST_GROUP << endl;
    229     name[L] = delim;
    230 #endif
    231 
    232     return GID;
    233 }
    234 
    235 // Use this function for L > 32
     202// Use this function for L > 16
    236203inline int PBGSIdentitySymbolTable::Lookup_or_Insert_Name(char* name, int hashvalue, int L)
    237204{
     
    244211
    245212    //Lookup
    246     GID = m_hashTable[group].Lookup_Name(name, hashvalue,L);
     213    GID = m_hashTable[group].Lookup_Name_17(name, hashvalue, L);
    247214
    248215    //Insert
Note: See TracChangeset for help on using the changeset viewer.