Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
editor_policy.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 __EDITOR_POLICY_H_INCLUDED__
10#define __EDITOR_POLICY_H_INCLUDED__
11
12#include "OccupancySpectrum.hpp"
13
14#include <utility> // std::forward, std::move
15
16namespace quetzal
17{
18namespace coalescence
19{
20namespace occupancy_spectrum
21{
22namespace editor_policy
23{
28{
29 static OccupancySpectrum edit(OccupancySpectrum &&M_j)
30 {
31 return std::move(M_j);
32 }
33}; // end struct identity
38{
39 static OccupancySpectrum edit(OccupancySpectrum &&M_j)
40 {
41 auto first = --(M_j.end());
42 while (first != M_j.begin() && *first == 0)
43 {
44 --first;
45 }
46 M_j.erase(++first, M_j.end());
47 return std::move(M_j);
48 }
49}; // end struct truncate_tail
50} // end namespace editor_policy
51} // namespace occupancy_spectrum
52} // end namespace coalescence
53} // end namespace quetzal
54
55#endif
An occupancy spectrum as defined in Becheler & Knowles, 2020.
Definition OccupancySpectrum.hpp:42
void erase(iterator first, iterator last)
erase a range of elements of the spectrum.
Definition OccupancySpectrum.hpp:204
Simulation of coalescence-based models of molecular evolution.
Definition coalescence.hpp:21
No editions are operated on the spectrum (default behavior)
Definition editor_policy.hpp:28
Edition consists in truncating the last nul elements of the spectrum to avoid useless iterations.
Definition editor_policy.hpp:38