20 template <
typename DATA_TYPE>
39 Span(
const std::vector<DATA_TYPE>& dataVector)
78 return !(*
this == rhs);
94 if (index < 0 || index >
myCount)
96 throw std::exception(
"Index out of range");
115 if ((offset + count) >
myCount)
117 throw std::exception(
"Subspan out of range");
126 inline std::vector<DATA_TYPE>&
assignTo(std::vector<DATA_TYPE>& destination)
const
137 inline std::vector<DATA_TYPE>&
appendTo(std::vector<DATA_TYPE>& destination)
const
140 destination.insert(destination.end(),
data(),
data() +
size());
Span(const DATA_TYPE *data, int count)
constructor for raw data
Definition: span.h:32
~Span()
destructor
Definition: span.h:46
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:137
bool operator!=(const Span< DATA_TYPE > &rhs) const
inequality operator
Definition: span.h:76
int myCount
Definition: span.h:146
Span & operator=(const Span &orig)
assignment operator
Definition: span.h:58
bool operator==(const Span< DATA_TYPE > &rhs) const
equality operator
Definition: span.h:70
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:105
Span(const std::vector< DATA_TYPE > &dataVector)
constructor for complete vector
Definition: span.h:39
A span represents a contiguous array of objects in memory.
Definition: span.h:21
const DATA_TYPE & operator[](int index) const
Array access to the elements in the array.
Definition: span.h:91
int size() const
Returns the count of objects in the array.
Definition: span.h:82
const DATA_TYPE * data() const
Returns a pointer to the underlying data.
Definition: span.h:88
const DATA_TYPE * myData
Definition: span.h:147
Span()
default constructor
Definition: span.h:25
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:112
Span(const Span &orig)
copy constructor
Definition: span.h:51
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:126
int sizeInBytes() const
Returns the size of the array in bytes.
Definition: span.h:85