Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
RestrictedGrowthString.hpp
1// Copyright 2021 Arnaud Becheler <abechele@umich.edu>
2
3/*********************************************************************** * This program is free software; you can
4 *redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free
5 *Software Foundation; either version 2 of the License, or * (at your option) any later version. *
6 * *
7 ***************************************************************************/
8
9#ifndef RESTRICTED_GROWTH_STRING
10#define RESTRICTED_GROWTH_STRING
11
12#include <iostream>
13#include <set>
14#include <vector>
15
17{
19{
20
21 public:
22 using block_type = unsigned int;
23
24 RestrictedGrowthString(std::vector<block_type> const &rgs) : m_rgs(rgs), m_blocks_id(retrieve_unique_blocks(rgs))
25 {
26 }
27
28 auto nBlocks() const
29 {
30 return m_blocks_id.size();
31 }
32
33 auto size() const
34 {
35 return m_rgs.size();
36 }
37
38 auto begin() const
39 {
40 return m_rgs.cbegin();
41 }
42
43 auto end() const
44 {
45 return m_rgs.cend();
46 }
47
48 bool operator==(RestrictedGrowthString const &other) const
49 {
50 return (this->m_rgs == other.m_rgs);
51 }
52
53 auto at(unsigned int n) const
54 {
55 return m_rgs.at(n);
56 }
57
58 private:
59 std::vector<block_type> m_rgs;
60 std::set<block_type> m_blocks_id;
61
62 std::set<block_type> retrieve_unique_blocks(std::vector<block_type> const &rgs)
63 {
64 std::set<block_type> ids;
65 for (auto const &it : rgs)
66 {
67 ids.insert(it);
68 }
69 return ids;
70 }
71};
72
73} // namespace quetzal::polymorphism::fuzzy_transfer_distance
74
75#endif
Summary statistics based on spatial partition of coalescent trees.
Definition polymorphism.hpp:28