source: tags/arb-6.0/PROBE/PT_complement.h

Last change on this file was 11060, checked in by westram, 10 years ago
File size: 1.4 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : PT_complement.h                                   //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in January 2013   //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#ifndef PT_COMPLEMENT_H
13#define PT_COMPLEMENT_H
14
15#ifndef PT_PROTOTYPES_H
16#include "pt_prototypes.h"
17#endif
18
19class Complement {
20    int complement[256];
21
22    static int calc_complement(int base); // DO NOT INLINE! (workaround a gcc-4.4.3-bug; see [9355] for details)
23
24public:
25    Complement() { for (int i = 0; i<256; ++i) complement[i] = calc_complement(i); }
26    int get(int base) const { return complement[base]; }
27};
28
29inline int get_complement(int base) {
30    static Complement c;
31    pt_assert(base >= 0 && base <= 255);
32    return c.get(base);
33}
34
35inline void complement_probe(char *Probe, int len) {
36    for (int i = 0; i<len; i++) {
37        Probe[i] = get_complement(Probe[i]);
38    }
39}
40
41#else
42#error PT_complement.h included twice
43#endif // PT_COMPLEMENT_H
Note: See TracBrowser for help on using the repository browser.