source: branches/properties/MULTI_PROBE/MP_GenerationDuplicates.cxx

Last change on this file was 16766, checked in by westram, 7 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1// ============================================================= //
2//                                                               //
3//   File      : MP_GenerationDuplicates.cxx                     //
4//   Purpose   :                                                 //
5//                                                               //
6//   Institute of Microbiology (Technical University Munich)     //
7//   http://www.arb-home.de/                                     //
8//                                                               //
9// ============================================================= //
10
11#include "MP_probe.hxx"
12#include "MultiProbe.hxx"
13
14bool GenerationDuplicates::insert(probe_combi_statistic *sondenkombi, bool &result, int depth) { // initial muss result true sein
15    int max_depth = mp_gl_awars.no_of_probes;
16
17    if (depth == max_depth) {
18        result = false;
19        return false;
20    }
21
22    if (! next[sondenkombi->get_probe_combi(depth)->probe_index]) { // sonde muss auf alle Faelle bis zuletzt eingetragen werden
23        if (depth == max_depth-1) {
24            next[sondenkombi->get_probe_combi(depth)->probe_index] = new GenerationDuplicates(1);
25            next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches] = 1;
26            return true;
27        }
28        else {
29            next[sondenkombi->get_probe_combi(depth)->probe_index] = new GenerationDuplicates(intern_size);
30            next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches] = 1;
31            return next[sondenkombi->get_probe_combi(depth)->probe_index]->insert(sondenkombi, result, depth+1);
32        }
33    }
34
35    result = result && next_mism[sondenkombi->get_probe_combi(depth)->allowed_mismatches];
36    next[sondenkombi->get_probe_combi(depth)->probe_index]->insert(sondenkombi, result, depth+1);       // man kann erst ganz unten entscheiden, ob doppelt oder nicht
37    return result;
38}
39
40GenerationDuplicates::GenerationDuplicates(int size) { // size muss die Groesse des Sondenarrays in ProbeValuation enthalten
41    intern_size = size;
42    next = new GenerationDuplicates*[size];
43    next_mism = new int[MAXMISMATCHES];
44    memset(next_mism, 0, MAXMISMATCHES * sizeof(int));
45    memset(next, 0, size * sizeof(GenerationDuplicates*));
46}
47
48GenerationDuplicates::~GenerationDuplicates() {
49    for (int i=0; i<intern_size; i++)
50        delete next[i];
51
52    delete [] next_mism;
53    delete next;
54}
Note: See TracBrowser for help on using the repository browser.