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;
294 return buffer+buffer_size;
304 return reverse_iterator(end());
314 return const_reverse_iterator(end());
324 return reverse_iterator(begin());
334 return const_reverse_iterator(begin());
368 return buffer[buffer_size-1];
378 return buffer[buffer_size-1];
439 if ( i>=buffer_size ) {
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.
iterator end() ecl_assert_throw_decl(StandardException)
virtual ~ConstantDynamicArray()
const_reverse_iterator rend() const ecl_assert_throw_decl(StandardException)
Embedded control libraries.
Parent class for array blueprints.
Array(const blueprints::ArrayBluePrint< T > &blueprint)
Blueprint constructor.
reference back() ecl_assert_throw_decl(StandardException)
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
formatters::ArrayFormatter< Type, DynamicStorage > Formatter
Formatter for this class.
Array(const unsigned int reserve_size)
Reserves storage for the array.
void implementApply(BaseType &array) const
const_iterator end() const ecl_assert_throw_decl(StandardException)
void operator=(const Array< Type, DynamicStorage > &array)
iterator begin() ecl_assert_throw_decl(StandardException)
size_type size() const
The size of the array.
reverse_iterator rbegin() ecl_assert_throw_decl(StandardException)
~Array()
Default destructor.
const_iterator begin() const ecl_assert_throw_decl(StandardException)
Array()
Default constructor.
#define ecl_assert_throw(expression, exception)
std::ptrdiff_t difference_type
const_reference operator[](size_type i) const ecl_assert_throw_decl(StandardException)
void clear()
Clear the array, deleting all storage space previously allocated.
const_reverse_iterator rbegin() const ecl_assert_throw_decl(StandardException)
ConstantDynamicArray()
Default constructor.
const_reference front() const ecl_assert_throw_decl(StandardException)
void resize(size_t n)
Resize the array, clearing whatever was in there before.
const_reference back() const ecl_assert_throw_decl(StandardException)
base_type instantiate()
Instantiate a copy of the object that is blueprinted.
std::reverse_iterator< iterator > reverse_iterator
reference front() ecl_assert_throw_decl(StandardException)
Convenience initialiser with bounds checking for fixed size containers.
#define ecl_assert_throw_decl(exception)
const_reference at(size_type i) const
A safe windowing class that opens onto array-like containers.
#define ecl_compile_time_concept_check(Model)
const Type * const_iterator
OutputStream & operator<<(OutputStream &ostream, Format< std::string > &formatter) ecl_assert_throw_decl(StandardException)
Blueprint for generating a cubic spline satisfying C2 constraints.
std::reverse_iterator< const_iterator > const_reverse_iterator
reverse_iterator rend() ecl_assert_throw_decl(StandardException)
reference at(size_type i)
static blueprints::ConstantDynamicArray< Type > Constant(size_t size, const Type &value)
Generates a constant array of the specified size.
Array(const Array< Type, DynamicStorage > &array)
Copy constructor.
void apply(base_type &array) const
Apply the blueprint to configure an existing object.
Dynamic size container with a few bells and whistles.
Stencil< Array< Type, DynamicStorage > > stencil(const unsigned int &start_index, const unsigned int &n) ecl_assert_throw_decl(StandardException)
Open a window (stencil) onto the array.
reference operator[](size_type i) ecl_assert_throw_decl(StandardException)
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.