21 template <
typename DATA_TYPE>
40 Span(
const std::vector<DATA_TYPE>& dataVector)
79 return !(*
this == rhs);
95 if (index < 0 || index >
myCount)
97 throw std::runtime_error(
"Index out of range");
116 if ((offset + count) >
myCount)
118 throw std::runtime_error(
"Subspan out of range");
127 inline std::vector<DATA_TYPE>&
assignTo(std::vector<DATA_TYPE>& destination)
const
138 inline std::vector<DATA_TYPE>&
appendTo(std::vector<DATA_TYPE>& destination)
const
141 destination.insert(destination.end(),
data(),
data() +
size());
Span(const DATA_TYPE *data, int count)
constructor for raw data
Definition: span.h:33
~Span()
destructor
Definition: span.h:47
std::vector< DATA_TYPE > & appendTo(std::vector< DATA_TYPE > &destination) const
Append the contents of the span to the end of the given vector Return the given vector.
Definition: span.h:138
bool operator!=(const Span< DATA_TYPE > &rhs) const
inequality operator
Definition: span.h:77
int myCount
Definition: span.h:147
Span & operator=(const Span &orig)
assignment operator
Definition: span.h:59
bool operator==(const Span< DATA_TYPE > &rhs) const
equality operator
Definition: span.h:71
Span slice(int offset)
Returns a new span that is a subset of the existing span from the offset to the end of the array...
Definition: span.h:106
Span(const std::vector< DATA_TYPE > &dataVector)
constructor for complete vector
Definition: span.h:40
A span represents a contiguous array of objects in memory.
Definition: span.h:22
const DATA_TYPE & operator[](int index) const
Array access to the elements in the array.
Definition: span.h:92
int size() const
Returns the count of objects in the array.
Definition: span.h:83
const DATA_TYPE * data() const
Returns a pointer to the underlying data.
Definition: span.h:89
const DATA_TYPE * myData
Definition: span.h:148
Span()
default constructor
Definition: span.h:26
Span slice(int offset, int count)
Returns a new span that is a subset of the existing span from the offset for a given count of the arr...
Definition: span.h:113
Span(const Span &orig)
copy constructor
Definition: span.h:52
std::vector< DATA_TYPE > & assignTo(std::vector< DATA_TYPE > &destination) const
Assign the contents of the span to the given vector replacing its contents Return the given vector...
Definition: span.h:127
int sizeInBytes() const
Returns the size of the array in bytes.
Definition: span.h:86