12 #ifndef ECL_CONTAINERS_ARRAY_DYNAMIC_NO_MEM_CHECK_HPP_ 13 #define ECL_CONTAINERS_ARRAY_DYNAMIC_NO_MEM_CHECK_HPP_ 22 #include "../definitions.hpp" 23 #include "../initialiser.hpp" 24 #include "../stencil.hpp" 39 namespace blueprints {
41 template <
typename Type>
class ConstantDynamicArray;
45 namespace formatters {
47 template <
typename Type,
size_t N>
class ArrayFormatter;
62 template<
typename Type>
128 template<
typename Type>
156 explicit Array() : buffer_size(0), buffer(NULL) {}
165 explicit Array(
const unsigned int reserve_size) : buffer_size(reserve_size), buffer(NULL) {
166 buffer =
new Type[reserve_size];
180 if ( array.
size() != 0 ) {
181 resize(array.
size());
182 std::copy(array.
begin(),array.
end(),begin());
220 if ( buffer != NULL ) {
245 if ( array.
size() == 0 ) {
248 resize(array.
size());
249 std::copy(array.
begin(),array.
end(),begin());
284 return buffer+buffer_size;
292 const_iterator
end()
const {
294 return buffer+buffer_size;
304 return reverse_iterator(end());
314 return const_reverse_iterator(end());
324 return reverse_iterator(begin());
332 const_reverse_iterator
rend()
const {
334 return const_reverse_iterator(begin());
368 return buffer[buffer_size-1];
378 return buffer[buffer_size-1];
438 reference
at(size_type i) {
439 if ( i>=buffer_size ) {
456 const_reference
at(size_type i)
const {
457 if ( i>=buffer_size ) {
473 size_type
size()
const {
return buffer_size; }
484 if ( buffer != NULL ) {
487 buffer =
new Type[n];
496 if ( buffer != NULL ) {
513 template <
typename OutputStream,
typename ElementType>
514 friend OutputStream& operator<<(OutputStream &ostream , const Array<ElementType,DynamicStorage> &array);
517 unsigned int buffer_size;
526 template <
typename OutputStream,
typename ElementType>
527 OutputStream& operator<<(OutputStream &ostream , const Array<ElementType,DynamicStorage> &array) {
530 for(
size_t i = 0; i < array.buffer_size; ++i )
532 ostream << array[i] <<
" ";
544 namespace blueprints {
557 template <
typename Type>
558 class ConstantDynamicArray:
public ArrayBluePrint< ConstantDynamicArray<Type> > {
599 std::fill_n(array.
begin(),reserve_size,val);
611 void apply(base_type& array)
const {
612 array.resize(reserve_size);
613 std::fill_n(array.
begin(),reserve_size,val);
Fixed size container with a few bells and whistles.
virtual ~ConstantDynamicArray()
Embedded control libraries.
Parent class for array blueprints.
Array(const blueprints::ArrayBluePrint< T > &blueprint)
Blueprint constructor.
const_reference at(size_type i) const
OutputStream & operator<<(OutputStream &ostream, Format< std::string > &formatter)
ConstantDynamicArray(size_t size, const Type &value)
Constructor that properly configures/initialises the blueprint.
virtual ~BluePrintFactory()
Fixed size containers with a few bells and whistles.
const Type & const_reference
const_iterator begin() const
const_reverse_iterator rend() const
void apply(base_type &array) const
Apply the blueprint to configure an existing object.
formatters::ArrayFormatter< Type, DynamicStorage > Formatter
Formatter for this class.
Array(const unsigned int reserve_size)
Reserves storage for the array.
void operator=(const Array< Type, DynamicStorage > &array)
const_reverse_iterator rbegin() const
~Array()
Default destructor.
Array()
Default constructor.
#define ecl_assert_throw(expression, exception)
std::ptrdiff_t difference_type
const_reference back() const
void clear()
Clear the array, deleting all storage space previously allocated.
reverse_iterator rbegin()
ConstantDynamicArray()
Default constructor.
const_reference operator[](size_type i) const
void resize(size_t n)
Resize the array, clearing whatever was in there before.
base_type instantiate()
Instantiate a copy of the object that is blueprinted.
size_type size() const
The size of the array.
std::reverse_iterator< iterator > reverse_iterator
Convenience initialiser with bounds checking for fixed size containers.
A safe windowing class that opens onto array-like containers.
#define ecl_compile_time_concept_check(Model)
const Type * const_iterator
Blueprint for generating a cubic spline satisfying C2 constraints.
std::reverse_iterator< const_iterator > const_reverse_iterator
reference at(size_type i)
static blueprints::ConstantDynamicArray< Type > Constant(size_t size, const Type &value)
Generates a constant array of the specified size.
Stencil< Array< Type, DynamicStorage > > stencil(const unsigned int &start_index, const unsigned int &n)
Open a window (stencil) onto the array.
Array(const Array< Type, DynamicStorage > &array)
Copy constructor.
reference operator[](size_type i)
const_iterator end() const
Dynamic size container with a few bells and whistles.
void implementApply(BaseType &array) const
const_reference front() const
BluePrintFactory< Array< Type, DynamicStorage > > Factory
Generates blueprints for this class.
ecl::Array< Type, ecl::DynamicStorage > base_type
Abstract representation of the class to be instantiated/configured.