Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
VectorLike.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/data/VectorLike.h"
25 #include <utility>
26 
27 namespace ska {
28 namespace cheetah {
29 namespace data {
30 
31 template <typename VectorType>
33 {
34 }
35 
36 template <typename VectorType>
37 VectorLike<VectorType>::VectorLike(AllocatorType const& allocator)
38  : _data(allocator)
39 {
40 }
41 
42 template <typename VectorType>
44 {
45 }
46 
47 template <typename VectorType>
48 template<typename... Args>
49 VectorLike<VectorType>::VectorLike(std::size_t n, Args&&... args)
50  : _data(n, std::forward<Args>(args)...)
51 {
52 }
53 
54 template <typename VectorType>
55 VectorLike<VectorType>::VectorLike(std::size_t n, const ValueType& value, AllocatorType const& allocator)
56  : _data(n,value, allocator)
57 {
58 }
59 
60 template <typename VectorType>
61 std::size_t VectorLike<VectorType>::size(void) const
62 {
63  return _data.size();
64 }
65 
66 template <typename VectorType>
67 void VectorLike<VectorType>::resize(std::size_t n, const ValueType &x)
68 {
69  _data.resize(n,x);
70 }
71 
72 template <typename VectorType>
73 typename VectorLike<VectorType>::Reference VectorLike<VectorType>::operator[](std::size_t n)
74 {
75  return _data[n];
76 }
77 
78 template <typename VectorType>
79 typename VectorLike<VectorType>::ConstReference VectorLike<VectorType>::operator[](std::size_t n) const
80 {
81  return _data[n];
82 }
83 
84 template <typename VectorType>
85 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::begin()
86 {
87  return _data.begin();
88 }
89 
90 template <typename VectorType>
91 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::begin() const
92 {
93  return _data.cbegin();
94 }
95 
96 template <typename VectorType>
97 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::cbegin() const
98 {
99  return _data.cbegin();
100 }
101 
102 template <typename VectorType>
103 typename VectorLike<VectorType>::ReverseIterator VectorLike<VectorType>::rbegin()
104 {
105  return _data.rbegin();
106 }
107 
108 template <typename VectorType>
109 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::end()
110 {
111  return _data.end();
112 }
113 
114 template <typename VectorType>
115 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::end() const
116 {
117  return _data.cend();
118 }
119 
120 template <typename VectorType>
121 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::cend() const
122 {
123  return _data.cend();
124 }
125 
126 template <typename VectorType>
127 typename VectorLike<VectorType>::ReverseIterator VectorLike<VectorType>::rend()
128 {
129  return _data.rend();
130 }
131 
132 template <typename VectorType>
133 typename VectorLike<VectorType>::Pointer VectorLike<VectorType>::data()
134 {
135  return _data.data();
136 }
137 
138 template <typename VectorType>
139 typename VectorLike<VectorType>::ConstPointer VectorLike<VectorType>::data() const
140 {
141  return _data.data();
142 }
143 
144 template <typename VectorType>
145 void VectorLike<VectorType>::push_back(ValueType const& value)
146 {
147  return _data.push_back(value);
148 }
149 
150 template <typename VectorType>
151 template<typename ...Args>
153 {
154  return _data.emplace_back(std::forward<Args>(values)...);
155 }
156 
157 template <typename VectorType>
158 void VectorLike<VectorType>::reserve(std::size_t size)
159 {
160  return _data.reserve(size);
161 }
162 
163 template <typename VectorType>
165 {
166  return _data.capacity();
167 }
168 
169 template <typename VectorType>
171 {
172  return _data.swap(v);
173 }
174 
175 template <typename VectorType>
176 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::erase(Iterator pos)
177 {
178  return _data.erase(pos);
179 }
180 
181 template <typename VectorType>
182 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::erase(Iterator first, Iterator last)
183 {
184  return _data.erase(first,last);
185 }
186 
187 template <typename VectorType>
188 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::insert(Iterator pos, const ValueType& value)
189 {
190  return _data.insert(pos, value);
191 }
192 
193 template <typename VectorType>
194 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::insert(ConstIterator pos, ValueType&& value)
195 {
196  return _data.insert(pos, std::move(value));
197 }
198 
199 template <typename VectorType>
200 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::insert(ConstIterator pos, const ValueType& value)
201 {
202  return _data.insert(pos, value);
203 }
204 
205 template <typename VectorType>
206 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::insert(Iterator pos, ValueType&& value)
207 {
208  return _data.insert(pos, std::move(value));
209 }
210 
211 template <typename VectorType>
212 template<typename...Args>
213 typename VectorLike<VectorType>::Iterator VectorLike<VectorType>::emplace(Iterator pos, Args&&... values)
214 {
215  return _data.emplace(pos, std::forward<Args>(values)...);
216 }
217 
218 template <typename VectorType>
219 template<typename...Args>
220 typename VectorLike<VectorType>::ConstIterator VectorLike<VectorType>::emplace(ConstIterator pos, Args&&... values)
221 {
222  return _data.emplace(pos, std::forward<Args>(values)...);
223 }
224 
225 template <typename VectorType>
226 inline typename VectorLike<VectorType>::ValueType& VectorLike<VectorType>::front()
227 {
228  return _data.front();
229 }
230 
231 template <typename VectorType>
232 inline typename VectorLike<VectorType>::ValueType const& VectorLike<VectorType>::front() const
233 {
234  return _data.front();
235 }
236 
237 template <typename VectorType>
238 inline typename VectorLike<VectorType>::ValueType& VectorLike<VectorType>::back()
239 {
240  return _data.back();
241 }
242 
243 template <typename VectorType>
244 inline typename VectorLike<VectorType>::ValueType const& VectorLike<VectorType>::back() const
245 {
246  return _data.back();
247 }
248 
249 template <typename VectorType>
250 inline bool VectorLike<VectorType>::empty() const
251 {
252  return _data.empty();
253 }
254 
255 template <typename VectorType>
257 {
258  _data.clear();
259 }
260 
261 template <typename VectorType>
263 {
264  for(auto it=v.begin(); it != v.end(); ++it) {
265  _data.push_back(*it);
266  }
267  return *this;
268 }
269 
270 template <typename VectorType>
271 typename VectorLike<VectorType>::AllocatorType VectorLike<VectorType>::allocator() const
272 {
273  return _data.get_allocator();
274 }
275 
276 
277 } // namespace data
278 } // namespace cheetah
279 } // namespace ska
ValueType const & front() const
the first emelment
Definition: VectorLike.cpp:232
ValueType const & back() const
the last emelment
Definition: VectorLike.cpp:244
void resize(std::size_t size, const ValueType &x=ValueType())
Resize the vector.
Definition: VectorLike.cpp:67
Pointer data()
Return a pointer pointing to the start of the vector.
Definition: VectorLike.cpp:133
ConstIterator cend() const
A constant iterator pointing to the end of the vector.
Definition: VectorLike.cpp:121
std::size_t size() const
Retrieve the size of the underlying vector.
Definition: VectorLike.cpp:61
void emplace_back(Args &&... value)
Appends element to end of vector using the move operator.
Definition: VectorLike.cpp:152
Class that wraps objects that export the std::vector interface.
Definition: VectorLike.h:44
Some limits and constants for FLDO.
Definition: Brdz.h:35
void clear()
clear the data
Definition: VectorLike.cpp:256
void push_back(ValueType const &value)
Appends element to end of vector.
Definition: VectorLike.cpp:145
void reserve(std::size_t size)
Reserve space for this many elements.
Definition: VectorLike.cpp:158
void swap(VectorLike &v)
swaps the contents of this vector_base with another vector
Definition: VectorLike.cpp:170
ReverseIterator rbegin()
A reverse iterator pointing to the end of the vector (i.e the last element).
Definition: VectorLike.cpp:103
VectorLike()
Construct a VectorLike instance.
Definition: VectorLike.cpp:32
Iterator end()
An iterator pointing to the end of the vector.
Definition: VectorLike.cpp:109
bool empty() const
return true if the vector is empty
Definition: VectorLike.cpp:250
std::size_t capacity() const
The reseved size of the vector.
Definition: VectorLike.cpp:164
Iterator insert(Iterator pos, const ValueType &value)
insert a value in the vector_base
Definition: VectorLike.cpp:188
Iterator erase(Iterator pos)
erase the element from a given position or a range of positions
Definition: VectorLike.cpp:176
Iterator begin()
An iterator pointing to the start of the vector.
Definition: VectorLike.cpp:85