template<typename T>
RepeatArray class
The RepeatArray class is a template class that represents an array that repeats its elements. It has a constructor that takes a value and a size as parameters and initializes all elements of the array with the given value.
0 1 2 3 4 +---+---+---+---+---+ | 5 | 5 | 5 | 5 | 5 | <-- All elements have the same value +---+---+---+---+---+
Public types
- class Iterator
Constructors, destructors, conversion operators
- RepeatArray(const T& value, size_t size)
Public functions
Function documentation
template<typename T>
RepeatArray<T>:: RepeatArray(const T& value,
size_t size)
| Parameters | |
|---|---|
| value in | Value to initialize array elements with. |
| size in | Number of elements in array. |
Constructor for RepeatArray class.
Initializes a RepeatArray with the given value repeated size number of times.
template<typename T>
T RepeatArray<T>:: operator[](size_t) const
| Returns | The value stored in the RepeatArray. |
|---|
Overloads the subscript operator [] to return the value stored in the RepeatArray.
template<typename T>
size_t RepeatArray<T>:: size() const
| Returns | the value of the variable "size" as a size_t data type. |
|---|
Returns the number of elements in the RepeatArray.
template<typename T>
Iterator RepeatArray<T>:: end() const
| Returns | Iterator pointing past the last element. |
|---|
Returns an iterator pointing to the past-the-end element of the container.
This ends iteration at the end of the underlying container. Trying to dereference the returned iterator results in undefined behavior.