source: trunk/symbol_table/src/compare_strategy.hpp @ 2053

Last change on this file since 2053 was 2053, checked in by ksherdy, 7 years ago

Specialized on LGTH.

File size: 4.5 KB
Line 
1#ifndef COMPARE_STRATEGY_HPP
2#define COMPARE_STRATEGY_HPP
3
4/* Compare Strategy */
5class compare_strategy {
6public:
7    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0);
8protected:
9    compare_strategy() {}
10};
11
12///* Length and Type specific comparison */
13//template<uint32_t LGTH, class TYPE>
14//class identity_strategy_t: public compare_strategy {
15//public:
16//    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
17//      return overlap_compare<LGTH, TYPE>(x,y);
18//    }
19//};
20
21/* Length specific comparison */
22template<uint32_t LGTH>
23class compare_strategy_t: public compare_strategy {
24public:
25    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
26        return overlap_compare<LGTH, BitBlock>(x,y);
27    }
28};
29
30/* Default */
31template<> class compare_strategy_t<0>: public compare_strategy {
32public:
33    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
34        return mem_compare(x,y,lgth);
35    }
36};
37
38template<> class compare_strategy_t<1>: public compare_strategy {
39public:
40    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
41        return overlap_compare<1, uint8_t>(x,y);
42    }
43};
44
45template<> class compare_strategy_t<2>: public compare_strategy {
46public:
47    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
48        return overlap_compare<2, uint16_t>(x,y);
49    }
50};
51
52template<> class compare_strategy_t<3>: public compare_strategy {
53public:
54    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
55        return overlap_compare<3, uint16_t>(x,y);
56    }
57};
58
59template<> class compare_strategy_t<4>: public compare_strategy {
60public:
61    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
62        return overlap_compare<4, uint32_t>(x,y);
63    }
64};
65
66template<> class compare_strategy_t<5>: public compare_strategy {
67public:
68    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
69        return overlap_compare<5, uint32_t>(x,y);
70    }
71};
72
73template<> class compare_strategy_t<6>: public compare_strategy {
74public:
75    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
76        return overlap_compare<6, uint32_t>(x,y);
77    }
78};
79
80template<> class compare_strategy_t<7>: public compare_strategy {
81public:
82    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
83        return overlap_compare<7, uint32_t>(x,y);
84    }
85};
86
87template<> class compare_strategy_t<8>: public compare_strategy {
88public:
89    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
90        return overlap_compare<8, uint64_t>(x,y);
91    }
92};
93
94template<> class compare_strategy_t<9>: public compare_strategy {
95public:
96    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
97        return overlap_compare<9, uint64_t>(x,y);
98    }
99};
100
101template<> class compare_strategy_t<10>: public compare_strategy {
102public:
103    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
104        return overlap_compare<10, uint64_t>(x,y);
105    }
106};
107
108template<> class compare_strategy_t<11>: public compare_strategy {
109public:
110    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
111        return overlap_compare<11, uint64_t>(x,y);
112    }
113};
114
115template<> class compare_strategy_t<12>: public compare_strategy {
116public:
117    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
118        return overlap_compare<12, uint64_t>(x,y);
119    }
120};
121
122template<> class compare_strategy_t<13>: public compare_strategy {
123public:
124    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
125        return overlap_compare<13, uint64_t>(x,y);
126    }
127};
128
129template<> class compare_strategy_t<14>: public compare_strategy {
130public:
131    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
132        return overlap_compare<14, uint64_t>(x,y);
133    }
134};
135
136template<> class compare_strategy_t<15>: public compare_strategy {
137public:
138    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
139        return overlap_compare<15, uint64_t>(x,y);
140    }
141};
142
143///* Default */
144//class identity_strategy_d: public compare_strategy {
145//public:
146//    static IDISA_ALWAYS_INLINE bool compare(uint8_t * x, uint8_t * y, const uint32_t lgth=0) {
147//      return mem_compare(x,y,lgth);
148//    }
149//};
150
151
152#endif // COMPARE_STRATEGY_HPP
Note: See TracBrowser for help on using the repository browser.