Ignore:
Timestamp:
Nov 7, 2011, 3:22:00 PM (8 years ago)
Author:
vla24
Message:

SymbolTable?: Update symtab library for dictionary div2 delimiter. Fixed some compile errors for log grouping

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symtab/bitstream_hash_table.cpp

    r1518 r1665  
    88
    99BitStreamHashTable::BitStreamHashTable()
    10     :g_tableSize(DEFAULT_TABLE_SIZE)
     10    :m_tableSize(DEFAULT_TABLE_SIZE)
    1111{
    12     g_table = allocateHashTable(g_tableSize);
     12    m_table = allocateHashTable(m_tableSize);
    1313}
    1414
    1515BitStreamHashTable::~BitStreamHashTable()
    1616{
    17     deallocateHashTable(g_tableSize, g_table);
     17    deallocateHashTable(m_tableSize, m_table);
    1818}
    1919
     
    2121unsigned int BitStreamHashTable::Lookup_Name_17(char * name, const int hashvalue, int L)
    2222{
    23     unsigned int bucket = getBucket(hashvalue, g_tableSize);
     23    unsigned int bucket = getBucket(hashvalue, m_tableSize);
    2424
    2525    // Look up the value in the chain
    26     for(CHAIN* chain = g_table[bucket]; chain != NULL; chain = chain->next) {
    27 #if DEBUG_BHT
     26    for(CHAIN* chain = m_table[bucket]; chain != NULL; chain = chain->next) {
     27#if DEBUm_BHT
    2828        printf ("Check symbol: %s\n", chain->key);
    2929#endif
    3030        if( simd_compare ((unsigned char*)chain->key, (unsigned char*)name, L) )
    3131        {
    32 #if DEBUG_BHT
     32#if DEBUm_BHT
    3333            printf ("Found GID: %i\n", chain->GID);
    3434#endif
     
    3737    }
    3838
    39 #if DEBUG_BHT
     39#if DEBUm_BHT
    4040    printf ("Not Found GID: %i\n", 0);
    4141#endif
     
    4545void BitStreamHashTable::Insert_Name(const char * name, const int hashvalue, const unsigned int gid)
    4646{
    47     unsigned int bucket = getBucket(hashvalue, g_tableSize);
     47    unsigned int bucket = getBucket(hashvalue, m_tableSize);
    4848
    4949    // If it was not found, add it
    50     CHAIN* next = g_table[bucket];
     50    CHAIN* next = m_table[bucket];
    5151    unsigned int chainlgth = chainLength(next);
    5252    if (chainlgth == MAX_CHAIN)
     
    5454        //current chain length is maximum, expand the table
    5555        expandHashTable();
    56         bucket = getBucket(hashvalue, g_tableSize);
    57         next = g_table[bucket];
     56        bucket = getBucket(hashvalue, m_tableSize);
     57        next = m_table[bucket];
    5858    }
    5959    CHAIN* curr = (CHAIN*) malloc(sizeof(CHAIN));
     
    6262    curr->hashvalue = hashvalue;
    6363    curr->GID = gid;
    64     g_table[bucket] = curr;
     64    m_table[bucket] = curr;
    6565
    66 #if DEBUG_BHT
    67     printf ("Given GID: %i | Stored GID: %i\n", gid, g_table[hash]->GID);
     66#if DEBUm_BHT
     67    printf ("Given GID: %i | Stored GID: %i\n", gid, m_table[hash]->GID);
    6868#endif
    6969}
     
    7171void BitStreamHashTable::Insert_Name(const char * name, const int hashvalue, const unsigned int gid, const unsigned int lgth)
    7272{
    73     unsigned int bucket = getBucket(hashvalue, g_tableSize);
     73    unsigned int bucket = getBucket(hashvalue, m_tableSize);
    7474
    7575    // If it was not found, add it
    76     CHAIN* next = g_table[bucket];
     76    CHAIN* next = m_table[bucket];
    7777    unsigned int chainlgth = chainLength(next);
    7878    if (chainlgth == MAX_CHAIN)
     
    8080        //current chain length is maximum, expand the table
    8181        expandHashTable();
    82         bucket = getBucket(hashvalue, g_tableSize);
    83         next = g_table[bucket];
     82        bucket = getBucket(hashvalue, m_tableSize);
     83        next = m_table[bucket];
    8484    }
    8585    CHAIN* curr = (CHAIN*) malloc(sizeof(CHAIN));
     
    8989    curr->GID = gid;
    9090    curr->lgth = lgth;
    91     g_table[bucket] = curr;
     91    m_table[bucket] = curr;
    9292
    93 #if DEBUG_BHT
    94     printf ("Given GID: %i | Stored GID: %i\n", gid, g_table[hash]->GID);
     93#if DEBUm_BHT
     94    printf ("Given GID: %i | Stored GID: %i\n", gid, m_table[hash]->GID);
    9595#endif
    9696}
     
    101101    CHAIN** tempTable = allocateHashTable(tempTableSize);
    102102
    103     for(unsigned int bucket = 0; bucket < g_tableSize; bucket++)
     103    for(unsigned int bucket = 0; bucket < m_tableSize; bucket++)
    104104    {
    105         CHAIN* curr = g_table[bucket];
    106         g_table[bucket] = NULL;
     105        CHAIN* curr = m_table[bucket];
     106        m_table[bucket] = NULL;
    107107
    108108        while (curr != NULL)
     
    121121    }
    122122
    123     // Deallocate g_table
    124     deallocateHashTable(g_tableSize, g_table);
     123    // Deallocate m_table
     124    deallocateHashTable(m_tableSize, m_table);
    125125
    126     // Reassign g_table
    127     g_table = tempTable;
    128     g_tableSize = tempTableSize;
     126    // Reassign m_table
     127    m_table = tempTable;
     128    m_tableSize = tempTableSize;
    129129}
    130130
    131131void BitStreamHashTable::Print_Symbol_Table_Distribution()
    132132{
    133     for(unsigned int bucket = 0; bucket < g_tableSize; bucket++)
     133    for(unsigned int bucket = 0; bucket < m_tableSize; bucket++)
    134134    {
    135         int items = chainLength(g_table[bucket]);
     135        int items = chainLength(m_table[bucket]);
    136136        if (items >= 1)
    137137        {
Note: See TracChangeset for help on using the changeset viewer.