Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Types | Public Member Functions | List of all members
ska::cheetah::data::VectorLike< VectorType > Class Template Reference

Class that wraps objects that export the std::vector interface. More...

#include <cheetah/data/VectorLike.h>

Inheritance diagram for ska::cheetah::data::VectorLike< VectorType >:
Inheritance graph
Collaboration diagram for ska::cheetah::data::VectorLike< VectorType >:
Collaboration graph

Public Types

typedef VectorType::iterator Iterator
 
typedef VectorType::const_iterator ConstIterator
 
typedef VectorType::reverse_iterator ReverseIterator
 
typedef VectorType::pointer Pointer
 
typedef VectorType::const_pointer ConstPointer
 
typedef VectorType::reference Reference
 
typedef VectorType::const_reference ConstReference
 
typedef VectorType::value_type ValueType
 
typedef VectorType::allocator_type AllocatorType
 

Public Member Functions

 VectorLike ()
 Construct a VectorLike instance.
 
 VectorLike (AllocatorType const &allocator)
 Construct a VectorLike instance with an explicit allocator.
 
template<typename... Args>
 VectorLike (std::size_t n, Args &&... args)
 Construct a VectorLike instance of a given size. More...
 
 VectorLike (std::size_t n, const ValueType &value, AllocatorType const &allocator=AllocatorType())
 Construct a filled VectorLike instance of a given size. More...
 
std::size_t size () const
 Retrieve the size of the underlying vector.
 
ValueType const & front () const
 the first emelment
 
ValueType & front ()
 
ValueType const & back () const
 the last emelment
 
ValueType & back ()
 
void resize (std::size_t size, const ValueType &x=ValueType())
 Resize the vector. More...
 
Reference operator[] (std::size_t n)
 Subscript access to the data contained in the underlying vector. More...
 
ConstReference operator[] (std::size_t n) const
 Subscript Read-only access to the data contained in the underlying vector. More...
 
Iterator begin ()
 An iterator pointing to the start of the vector. More...
 
ConstIterator begin () const
 A constant iterator pointing to the start of the vector. More...
 
ConstIterator cbegin () const
 
ReverseIterator rbegin ()
 A reverse iterator pointing to the end of the vector (i.e the last element).
 
Iterator end ()
 An iterator pointing to the end of the vector. More...
 
ConstIterator end () const
 A constant iterator pointing to the end of the vector. More...
 
ConstIterator cend () const
 A constant iterator pointing to the end of the vector. More...
 
ReverseIterator rend ()
 
Pointer data ()
 Return a pointer pointing to the start of the vector. More...
 
ConstPointer data () const
 Return a constant pointer pointing to the start of the vector. More...
 
void push_back (ValueType const &value)
 Appends element to end of vector. More...
 
template<typename ... Args>
void emplace_back (Args &&... value)
 Appends element to end of vector using the move operator. More...
 
void reserve (std::size_t size)
 Reserve space for this many elements. More...
 
std::size_t capacity () const
 The reseved size of the vector. More...
 
void swap (VectorLike &v)
 swaps the contents of this vector_base with another vector More...
 
Iterator erase (Iterator pos)
 erase the element from a given position or a range of positions
 
Iterator erase (Iterator first, Iterator last)
 
Iterator insert (Iterator pos, const ValueType &value)
 insert a value in the vector_base
 
ConstIterator insert (ConstIterator pos, ValueType &&value)
 
ConstIterator insert (ConstIterator pos, const ValueType &value)
 
Iterator insert (Iterator pos, ValueType &&value)
 
template<typename... Args>
Iterator emplace (Iterator pos, Args &&...)
 
template<typename... Args>
ConstIterator emplace (ConstIterator pos, Args &&...)
 
SelfTypeoperator+= (SelfType const &)
 add the contents of the argument to the current vector
 
bool empty () const
 return true if the vector is empty
 
void clear ()
 clear the data
 
AllocatorType allocator () const
 return the allocator
 
template<typename... Args>
VectorLike< VectorType >::Iterator emplace (Iterator pos, Args &&... values)
 
template<typename... Args>
VectorLike< VectorType >::ConstIterator emplace (ConstIterator pos, Args &&... values)
 

Detailed Description

template<typename VectorType>
class ska::cheetah::data::VectorLike< VectorType >

Class that wraps objects that export the std::vector interface.

This class is used to provide interoperability between thrust vectors and std::vectors such that both can be used as template arguments for the Series class (from which TimeSeries, FrequencySeries, etc. are derived)

Template Parameters
VectorTypeThe underlying vector type to be wrapped

Definition at line 44 of file VectorLike.h.

Constructor & Destructor Documentation

◆ VectorLike() [1/2]

template<typename VectorType >
template<typename... Args>
ska::cheetah::data::VectorLike< VectorType >::VectorLike ( std::size_t  n,
Args &&...  args 
)
explicit

Construct a VectorLike instance of a given size.

Parameters
[in]nThe size of the underlying vector.

Definition at line 49 of file VectorLike.cpp.

50  : _data(n, std::forward<Args>(args)...)
51 {
52 }

◆ VectorLike() [2/2]

template<typename VectorType >
ska::cheetah::data::VectorLike< VectorType >::VectorLike ( std::size_t  n,
const ValueType &  value,
AllocatorType const &  allocator = AllocatorType() 
)
explicit

Construct a filled VectorLike instance of a given size.

Parameters
[in]nThe size of the underlying vector.
[in]valueThe fill value

Definition at line 55 of file VectorLike.cpp.

56  : _data(n,value, allocator)
57 {
58 }
AllocatorType allocator() const
return the allocator
Definition: VectorLike.cpp:271

Member Function Documentation

◆ begin() [1/2]

template<typename VectorType >
VectorLike< VectorType >::Iterator ska::cheetah::data::VectorLike< VectorType >::begin ( )

An iterator pointing to the start of the vector.

Returns
A non-const iterator.

Definition at line 85 of file VectorLike.cpp.

86 {
87  return _data.begin();
88 }

◆ begin() [2/2]

template<typename VectorType >
VectorLike< VectorType >::ConstIterator ska::cheetah::data::VectorLike< VectorType >::begin ( ) const

A constant iterator pointing to the start of the vector.

Returns
A const iterator.

Definition at line 91 of file VectorLike.cpp.

92 {
93  return _data.cbegin();
94 }

◆ capacity()

template<typename VectorType >
std::size_t ska::cheetah::data::VectorLike< VectorType >::capacity ( ) const

The reseved size of the vector.

Returns
The number of elements reserved

Definition at line 164 of file VectorLike.cpp.

165 {
166  return _data.capacity();
167 }

◆ cend()

template<typename VectorType >
VectorLike< VectorType >::ConstIterator ska::cheetah::data::VectorLike< VectorType >::cend ( ) const

A constant iterator pointing to the end of the vector.

Returns
A const iterator.

Definition at line 121 of file VectorLike.cpp.

122 {
123  return _data.cend();
124 }

◆ data() [1/2]

template<typename VectorType >
VectorLike< VectorType >::Pointer ska::cheetah::data::VectorLike< VectorType >::data ( )

Return a pointer pointing to the start of the vector.

Returns
A pointer to the start of the vector

Definition at line 133 of file VectorLike.cpp.

134 {
135  return _data.data();
136 }

◆ data() [2/2]

template<typename VectorType >
VectorLike< VectorType >::ConstPointer ska::cheetah::data::VectorLike< VectorType >::data ( ) const

Return a constant pointer pointing to the start of the vector.

Returns
A const pointer to the start of the vector

Definition at line 139 of file VectorLike.cpp.

140 {
141  return _data.data();
142 }

◆ emplace_back()

template<typename VectorType >
template<typename ... Args>
void ska::cheetah::data::VectorLike< VectorType >::emplace_back ( Args &&...  value)

Appends element to end of vector using the move operator.

Parameters
[in]valueelement to add to end of vector

Definition at line 152 of file VectorLike.cpp.

153 {
154  return _data.emplace_back(std::forward<Args>(values)...);
155 }

◆ end() [1/2]

template<typename VectorType >
VectorLike< VectorType >::Iterator ska::cheetah::data::VectorLike< VectorType >::end ( )

An iterator pointing to the end of the vector.

Returns
A non-const iterator.

Definition at line 109 of file VectorLike.cpp.

110 {
111  return _data.end();
112 }

◆ end() [2/2]

template<typename VectorType >
VectorLike< VectorType >::ConstIterator ska::cheetah::data::VectorLike< VectorType >::end ( ) const

A constant iterator pointing to the end of the vector.

Returns
A const iterator.

Definition at line 115 of file VectorLike.cpp.

116 {
117  return _data.cend();
118 }

◆ operator[]() [1/2]

template<typename VectorType >
VectorLike< VectorType >::Reference ska::cheetah::data::VectorLike< VectorType >::operator[] ( std::size_t  n)

Subscript access to the data contained in the underlying vector.

Parameters
[in]nThe index of the elemment to be accessed.
Returns
Read/write reference to the data.

Definition at line 73 of file VectorLike.cpp.

74 {
75  return _data[n];
76 }

◆ operator[]() [2/2]

template<typename VectorType >
VectorLike< VectorType >::ConstReference ska::cheetah::data::VectorLike< VectorType >::operator[] ( std::size_t  n) const

Subscript Read-only access to the data contained in the underlying vector.

Parameters
[in]nThe index of the elemment to be accessed.
Returns
Read reference to the data.

Definition at line 79 of file VectorLike.cpp.

80 {
81  return _data[n];
82 }

◆ push_back()

template<typename VectorType >
void ska::cheetah::data::VectorLike< VectorType >::push_back ( ValueType const &  value)

Appends element to end of vector.

Parameters
[in]valueelement to add to end of vector

Definition at line 145 of file VectorLike.cpp.

146 {
147  return _data.push_back(value);
148 }

◆ rend()

template<typename VectorType >
VectorLike< VectorType >::ReverseIterator ska::cheetah::data::VectorLike< VectorType >::rend ( )

@ brief A reverse iterator pointing to the beginning of the vector

Definition at line 127 of file VectorLike.cpp.

128 {
129  return _data.rend();
130 }

◆ reserve()

template<typename VectorType >
void ska::cheetah::data::VectorLike< VectorType >::reserve ( std::size_t  size)

Reserve space for this many elements.

Parameters
[in]sizeThe number of elements

Definition at line 158 of file VectorLike.cpp.

159 {
160  return _data.reserve(size);
161 }
std::size_t size() const
Retrieve the size of the underlying vector.
Definition: VectorLike.cpp:61

◆ resize()

template<typename VectorType >
void ska::cheetah::data::VectorLike< VectorType >::resize ( std::size_t  size,
const ValueType &  x = ValueType() 
)

Resize the vector.

Parameters
[in]sizeThe new size of the vector

Definition at line 67 of file VectorLike.cpp.

68 {
69  _data.resize(n,x);
70 }

◆ swap()

template<typename VectorType >
void ska::cheetah::data::VectorLike< VectorType >::swap ( VectorLike< VectorType > &  v)

swaps the contents of this vector_base with another vector

Parameters
vThe vector with which to swap.

Definition at line 170 of file VectorLike.cpp.

171 {
172  return _data.swap(v);
173 }

The documentation for this class was generated from the following files: