A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
range.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_UTILS_CORE_RANGE_H_
2 #define GENESIS_UTILS_CORE_RANGE_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2017 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 namespace genesis {
35 namespace utils {
36 
37 // =================================================================================================
38 // Range
39 // =================================================================================================
40 
44 template <typename IteratorType>
45 class Range
46 {
47 public:
48 
49  // -------------------------------------------------------------------------
50  // Member Types
51  // -------------------------------------------------------------------------
52 
53  using iterator = IteratorType;
54 
55  // -------------------------------------------------------------------------
56  // Constructor and Rule of Five
57  // -------------------------------------------------------------------------
58 
59  Range () = default;
60 
61  template <class Container>
62  Range ( Container& cont )
63  : begin_( cont.begin() )
64  , end_( cont.end() )
65  {}
66 
67  template <class Container>
68  Range ( Container const& cont )
69  : begin_( cont.begin() )
70  , end_( cont.end() )
71  {}
72 
74  : begin_(begin)
75  , end_(end)
76  {}
77 
78  Range( Range const& ) = default;
79  Range( Range&& ) = default;
80 
81  Range& operator= ( Range const& ) = default;
82  Range& operator= ( Range&& ) = default;
83 
84  ~Range() = default;
85 
86  // -------------------------------------------------------------------------
87  // Iterators
88  // -------------------------------------------------------------------------
89 
91  {
92  return begin_;
93  }
94 
96  {
97  return end_;
98  }
99 
100  /*
101  const_iterator cbegin()
102  {
103  return RangeIterator<const value_type> (*this);
104  }
105 
106  const_iterator cend()
107  {
108  return RangeIterator<const value_type> (*this, size());
109  }
110  */
111 
112  // -------------------------------------------------------------------------
113  // Element Access
114  // -------------------------------------------------------------------------
115 
116  /*
117  reference operator[] (size_type n)
118  {
119  return *(content_[n]);
120  }
121 
122  const_reference operator[] (size_type n) const
123  {
124  return *(content_[n]);
125  }
126 
127  reference at (size_type n)
128  {
129  return *(content_.at(n));
130  }
131 
132  const_reference at (size_type n) const
133  {
134  return *(content_.at(n));
135  }
136 
137  reference front()
138  {
139  return *(content_.front());
140  }
141 
142  const_reference front() const
143  {
144  return *(content_.front());
145  }
146 
147  reference back()
148  {
149  return *(content_.back());
150  }
151 
152  const_reference back() const
153  {
154  return *(content_.back());
155  }
156  */
157 
158  // -------------------------------------------------------------------------
159  // Data Members
160  // -------------------------------------------------------------------------
161 
162 private:
163 
164  iterator begin_;
165  iterator end_;
166 
167 };
168 
169 } // namespace utils
170 } // namespace genesis
171 
172 #endif // include guard
Range(Container const &cont)
Definition: range.hpp:68
iterator begin()
Definition: range.hpp:90
Range(iterator begin, iterator end)
Definition: range.hpp:73
iterator end()
Definition: range.hpp:95
Range(Container &cont)
Definition: range.hpp:62
IteratorType iterator
Definition: range.hpp:53
Range & operator=(Range const &)=default