Go to the documentation of this file.
48 for (
unsigned int i = 0; i <
_size; i++)
107 void resize(
unsigned int size,
const T & default_value);
113 unsigned int size()
const;
123 const T &
operator[](
const unsigned int i)
const;
201 template <
typename T>
205 for (
unsigned int i = 0; i < _size; i++)
209 template <
typename T>
216 template <
typename T>
220 if (size <= _allocated_size)
224 _data_ptr.reset(
new T[size]);
225 mooseAssert(_data_ptr,
"Failed to allocate MooseArray memory!");
227 _data = _data_ptr.get();
228 _allocated_size = size;
233 template <
typename T>
237 if (size > _allocated_size)
239 T * new_pointer =
new T[size];
240 mooseAssert(new_pointer,
"Failed to allocate MooseArray memory!");
243 for (
unsigned int i = 0; i < _size; i++)
244 new_pointer[i] = _data[i];
246 _data_ptr.reset(new_pointer);
247 _data = _data_ptr.get();
248 _allocated_size = size;
251 for (
unsigned int i = _size; i < size; i++)
252 _data[i] = default_value;
257 template <
typename T>
264 template <
typename T>
267 mooseAssert(i < _size,
268 "Access out of bounds in MooseArray (i: " << i <<
" size: " << _size <<
")");
273 template <
typename T>
276 mooseAssert(i < _size,
277 "Access out of bounds in MooseArray (i: " << i <<
" size: " << _size <<
")");
282 template <
typename T>
292 template <
typename T>
302 template <
typename T>
309 _allocated_size = rhs.size();
312 template <
typename T>
316 unsigned int rhs_size = rhs.size();
320 for (
unsigned int i = 0; i < rhs_size; i++)
326 template <
typename T>
334 for (
unsigned int i = 0; i < _size; i++)
335 _data[i] = rhs.
_data[i];
344 return std::vector<T>(_data, _data + _size);
351 for (
unsigned int i = 0; i < a.size(); i++)
void setAllValues(const T &value)
Sets all values of the array to the passed in value.
MooseArray< T > & operator=(const std::vector< T > &rhs)
Actual operator=...
MooseArray(const MooseArray &rhs)
std::vector< T > stdVector() const
Extremely inefficient way to produce a std::vector from a MooseArray!
unsigned int _allocated_size
Number of allocated memory positions for storage.
void freeDoubleMooseArray(MooseArray< MooseArray< T >> &a)
std::unique_ptr< T[]> _data_ptr
Smart pointer storage.
void release()
Manually deallocates the data pointer.
void clear()
Change the number of elements the array can store to zero.
MooseArray(const unsigned int size, const T &default_value)
T & operator[](const unsigned int i)
Get element i out of the array.
MooseArray(const unsigned int size)
MooseArray()
Default constructor.
void resize(unsigned int size)
Change the number of elements the array can store.
const T * data() const
Reference to first element of array.
unsigned int _size
The current number of elements the array can hold.
void shallowCopy(const MooseArray &rhs)
Doesn't actually make a copy of the data.
void swap(MooseArray &rhs)
Swap memory in this object with the 'rhs' object.
unsigned int size() const
The number of elements that can currently be stored in the array.