source: tags/arb-6.0.5/PROBE_SET/fb_test.cxx

Last change on this file was 8309, checked in by westram, 12 years ago
  • moved much code into static scope

(partly reverted by [8310])

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : fb_test.cxx                                       //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Coded by Wolfram Foerster in October 2002                     //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#include "ps_bitmap.hxx"
13#include "ps_node.hxx"
14
15#include <iostream>
16
17#include <sys/times.h>
18
19static void PS_print_times() {
20    struct tms time;
21    times(&time);
22    printf("user (%.3f) system (%.3f)", (float)time.tms_utime/CLOCKS_PER_SEC, (float)time.tms_stime/CLOCKS_PER_SEC);
23}
24
25
26int main() {
27    PS_BitSet_Fast *x = new PS_BitSet_Fast(false, 20);
28    x->setTrue(0);
29    x->setTrue(3);
30    x->setTrue(4);
31    x->setTrue(7);
32    x->setTrue(10);
33    x->setTrue(11);
34    x->setTrue(14);
35    x->print(true, 20);
36    PS_BitSet::IndexSet indices;
37    x->getTrueIndices(indices);
38    printf(" true  indices (%2zu) : ", indices.size());
39    for (PS_BitSet::IndexSet::iterator i=indices.begin(); i != indices.end(); ++i) {
40        printf(" %4li", *i);
41    }
42    x->getTrueIndices(indices, 15);
43    printf("\n true  indices (%2zu) : ", indices.size());
44    for (PS_BitSet::IndexSet::iterator i=indices.begin(); i != indices.end(); ++i) {
45        printf(" %4li", *i);
46    }
47    x->getFalseIndices(indices);
48    printf("\n false indices (%2zu) : ", indices.size());
49    for (PS_BitSet::IndexSet::iterator i=indices.begin(); i != indices.end(); ++i) {
50        printf(" %4li", *i);
51    }
52    x->getFalseIndices(indices, 15);
53    printf("\n false indices (%2zu) : ", indices.size());
54    for (PS_BitSet::IndexSet::iterator i=indices.begin(); i != indices.end(); ++i) {
55        printf(" %4li", *i);
56    }
57    printf("\n");
58    delete x;
59    cout << "CLOCKS_PER_SEC : " << CLOCKS_PER_SEC << endl;
60    PS_print_times(); fflush(stdout);
61    for (long i = 0; i < 10000; ++i) {
62        for (long j = 0; j < 10000; ++j) {
63        }
64    }
65    PS_print_times();
66    return 0;
67
68    PS_BitMap *map = new PS_BitMap_Fast(false, 10);
69    for (long i = 0; i < 10; ++i) {
70        map->set(i, i, true);
71        map->set(0, i, true);
72        map->set(i, 0, true);
73        map->set(9, i, true);
74    }
75    map->print();
76
77    PS_FileBuffer *fb1 = new PS_FileBuffer("testdata", PS_FileBuffer::WRITEONLY);
78    map->save(fb1);
79    fb1->reinit("testdata", PS_FileBuffer::READONLY);
80    PS_BitMap_Counted *map2 = new PS_BitMap_Counted(fb1);
81    map2->print();
82
83    map2->setTrue(5, 8);
84    map2->print();
85    map2->recalcCounters();
86    map2->print();
87
88    delete map;
89    delete map2;
90    delete fb1;
91    return 0;
92
93    char str[] = "ABCDEFG";
94    int a      = 1;
95    int b      = 1;
96    printf("%i %c %i\n", a, str[a],    a+1); a++;
97    printf("%i %c %i\n", b, str[b+1], b+1); b++;
98    return 0;
99
100    ID2IDSet *s = new ID2IDSet;
101    s->insert(ID2IDPair(10, 40));
102    s->insert(ID2IDPair(8, 20));
103    s->insert(ID2IDPair(1, 4));
104    s->insert(ID2IDPair(8, 40));
105    s->insert(ID2IDPair(40, 70));
106    s->insert(ID2IDPair(20, 80));
107    for (ID2IDSetCIter i = s->begin(); i != s->end(); ++i) {
108        printf("%6i %6i\n", i->first, i->second);
109    }
110    delete s;
111    return 0;
112
113    PS_FileBuffer *fb2 = new PS_FileBuffer("testdata", true);
114    char *data = (char *)malloc(1024);
115    fb2->get(data, 4096);
116    fb2->get(data, 100);
117
118    free(data);
119    delete fb2;
120    return 0;
121}
Note: See TracBrowser for help on using the repository browser.