Changeset 2078 for trunk/symbol_table


Ignore:
Timestamp:
May 8, 2012, 12:05:34 PM (7 years ago)
Author:
ksherdy
Message:

Add.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symbol_table/src/hash_strategy.hpp

    r2069 r2078  
    33
    44#define MAX_HASH_BITS 17 // maximum length specific hash_strategy
     5
     6enum group_strategy { id, div2, logbase2 };
    57
    68/* Hash Strategy */
     
    1416
    1517/* Hash functions specialized on symbol length. */
    16 template<uint32_t LGTH>
     18template<uint32_t LGTH, int GROUP_STRATEGY>
    1719class hash_strategy_t: public hash_strategy {
    1820public:
     
    2123};
    2224
    23 /* Default */
    2425///////////////////////////////////////////////////////////////////////////////
    2526// Bit Space Hash
    2627///////////////////////////////////////////////////////////////////////////////
    27 template<> class hash_strategy_t<0> {
     28template<> class hash_strategy_t<0,id> {
    2829public:
    2930    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    3637// Byte Space Hash - Identity
    3738///////////////////////////////////////////////////////////////////////////////
    38 template<> class hash_strategy_t<1> {
     39template<> class hash_strategy_t<1,id> {
    3940public:
    4041    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    4445};
    4546
    46 template<> class hash_strategy_t<2> {
     47template<> class hash_strategy_t<2,id> {
    4748public:
    4849    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    5253};
    5354
    54 template<> class hash_strategy_t<3> {
     55template<> class hash_strategy_t<3,id> {
    5556public:
    5657    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    6061};
    6162
    62 template<> class hash_strategy_t<4>: public hash_strategy {
     63template<> class hash_strategy_t<4,id>: public hash_strategy {
    6364public:
    6465    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    6869};
    6970
    70 template<> class hash_strategy_t<5>: public hash_strategy {
     71template<> class hash_strategy_t<5,id>: public hash_strategy {
    7172public:
    7273    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    7677};
    7778
    78 template<> class hash_strategy_t<6>: public hash_strategy {
     79template<> class hash_strategy_t<6,id>: public hash_strategy {
    7980public:
    8081    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    8485};
    8586
    86 template<> class hash_strategy_t<7>: public hash_strategy {
     87template<> class hash_strategy_t<7,id>: public hash_strategy {
    8788public:
    8889    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    9596// Bit Space Hash - Identity
    9697///////////////////////////////////////////////////////////////////////////////
    97 template<> class hash_strategy_t<8>: public hash_strategy {
     98template<> class hash_strategy_t<8,id>: public hash_strategy {
    9899public:
    99100    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    103104};
    104105
    105 template<> class hash_strategy_t<9>: public hash_strategy {
     106template<> class hash_strategy_t<9,id>: public hash_strategy {
    106107public:
    107108    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    111112};
    112113
    113 template<> class hash_strategy_t<10>: public hash_strategy {
     114template<> class hash_strategy_t<10,id>: public hash_strategy {
    114115public:
    115116    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    119120};
    120121
    121 template<> class hash_strategy_t<11>: public hash_strategy {
     122template<> class hash_strategy_t<11,id>: public hash_strategy {
    122123public:
    123124    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    127128};
    128129
    129 template<> class hash_strategy_t<12>: public hash_strategy {
     130template<> class hash_strategy_t<12,id>: public hash_strategy {
    130131public:
    131132    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    135136};
    136137
    137 template<> class hash_strategy_t<13>: public hash_strategy {
     138template<> class hash_strategy_t<13,id>: public hash_strategy {
    138139public:
    139140    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    143144};
    144145
    145 template<> class hash_strategy_t<14>: public hash_strategy {
     146template<> class hash_strategy_t<14,id>: public hash_strategy {
    146147public:
    147148    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    151152};
    152153
    153 template<> class hash_strategy_t<15>: public hash_strategy {
     154template<> class hash_strategy_t<15,id>: public hash_strategy {
    154155public:
    155156    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    159160};
    160161
    161 template<> class hash_strategy_t<16>: public hash_strategy {
     162template<> class hash_strategy_t<16,id>: public hash_strategy {
    162163public:
    163164    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    167168};
    168169
    169 
    170 ///////////////////////////////////////////////////////////////////////////////
    171 // Log base 2
    172 ///////////////////////////////////////////////////////////////////////////////
    173 template<uint32_t LGTH>
    174 class log_hash_strategy_t: public hash_strategy {
    175 public:
    176     static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits);
    177     static IDISA_ALWAYS_INLINE uint32_t max_hashsize();
    178 };
    179 
    180 ///////////////////////////////////////////////////////////////////////////////
    181 // Byte Space Hash - Log 2
    182 ///////////////////////////////////////////////////////////////////////////////
    183 template<> class log_hash_strategy_t<1> {
     170///////////////////////////////////////////////////////////////////////////////
     171// Bit Space / Byte Space - Div 2 - Equivalent to identity hash function.
     172///////////////////////////////////////////////////////////////////////////////
     173template<uint32_t LGTH> class hash_strategy_t<LGTH,div2>: public hash_strategy_t<LGTH,id>{};
     174
     175///////////////////////////////////////////////////////////////////////////////
     176// Byte Space Hash - Log base 2
     177///////////////////////////////////////////////////////////////////////////////
     178template<> class hash_strategy_t<1,logbase2> {
    184179public:
    185180    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    189184};
    190185
    191 template<> class log_hash_strategy_t<2> {
     186template<> class hash_strategy_t<2,logbase2> {
    192187public:
    193188    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    197192};
    198193
    199 template<> class log_hash_strategy_t<4> {
     194template<> class hash_strategy_t<4,logbase2> {
    200195public:
    201196    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    205200};
    206201
    207 template<> class log_hash_strategy_t<8> {
     202template<> class hash_strategy_t<8,logbase2> {
    208203public:
    209204    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     
    214209
    215210///////////////////////////////////////////////////////////////////////////////
    216 // Bit Space Hash - Log 2
    217 ///////////////////////////////////////////////////////////////////////////////
    218 template<> class log_hash_strategy_t<16> {
     211// Bit Space Hash - Log base 2
     212///////////////////////////////////////////////////////////////////////////////
     213template<> class hash_strategy_t<16,logbase2> {
    219214public:
    220215    static IDISA_ALWAYS_INLINE uint64_t hash(const uint8_t * h0, const uint8_t * h1, const int32_t idx, const uint32_t slice_bits, const uint32_t hash_bits) {
Note: See TracChangeset for help on using the changeset viewer.