source:
branches/alilink/CONSENSUS_TREE/CT_hash.hxx
Last change on this file was 11401, checked in by westram, 11 years ago | |
---|---|
|
|
File size: 2.0 KB |
Line | |
---|---|
1 | // =============================================================== // |
2 | // // |
3 | // File : CT_hash.hxx // |
4 | // Purpose : // |
5 | // // |
6 | // Institute of Microbiology (Technical University Munich) // |
7 | // http://www.arb-home.de/ // |
8 | // // |
9 | // =============================================================== // |
10 | |
11 | #ifndef CT_HASH_HXX |
12 | #define CT_HASH_HXX |
13 | |
14 | #ifndef CT_PART_HXX |
15 | #include "CT_part.hxx" |
16 | #endif |
17 | #ifndef _GLIBCXX_SET |
18 | #include <set> |
19 | #endif |
20 | #ifndef _GLIBCXX_VECTOR |
21 | #include <vector> |
22 | #endif |
23 | |
24 | typedef PART *PARTptr; |
25 | typedef std::set<PARTptr, bool (*)(const PART *, const PART *)> PartSet; |
26 | typedef std::vector<PARTptr> PartVector; |
27 | |
28 | inline bool topological_less(const PART *p1, const PART *p2) { return p1->topological_cmp(p2)<0; } |
29 | |
30 | class PartRegistry : virtual Noncopyable { |
31 | PartSet parts; |
32 | PartSet artificial_parts; // these occurred in no tree |
33 | PartVector sorted; |
34 | size_t retrieved; |
35 | |
36 | bool registration_phase() const { return sorted.empty(); } |
37 | bool retrieval_phase() const { return !registration_phase(); } |
38 | |
39 | void merge_artificial_parts(); |
40 | |
41 | public: |
42 | PartRegistry() |
43 | : parts(topological_less), |
44 | artificial_parts(topological_less), |
45 | retrieved(0) |
46 | { |
47 | arb_assert(registration_phase()); |
48 | } |
49 | ~PartRegistry(); |
50 | |
51 | void put_part_from_complete_tree(PART*& part); |
52 | void put_part_from_partial_tree(PART*& part, const PART *partialTree); |
53 | void put_artificial_part(PART*& part); |
54 | |
55 | void build_sorted_list(double overall_weight); |
56 | PART *get_part(); |
57 | |
58 | size_t size() const { |
59 | if (registration_phase()) return parts.size()+artificial_parts.size(); |
60 | return sorted.size(); |
61 | } |
62 | }; |
63 | |
64 | #else |
65 | #error CT_hash.hxx included twice |
66 | #endif // CT_HASH_HXX |
Note: See TracBrowser
for help on using the repository browser.