12 #ifndef ECL_CONTAINERS_ARRAY_DYNAMIC_NO_MEM_CHECK_HPP_ 13 #define ECL_CONTAINERS_ARRAY_DYNAMIC_NO_MEM_CHECK_HPP_ 20 #include <ecl/config/macros.hpp> 21 #include <ecl/utilities/blueprints.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>
73 static blueprints::ConstantDynamicArray<Type> Constant(
size_t size,
const Type &value) {
74 return blueprints::ConstantDynamicArray<Type>(size,value);
76 virtual ~BluePrintFactory() {};
128 template<
typename Type>
134 typedef Type value_type;
135 typedef Type* iterator;
136 typedef const Type* const_iterator;
137 typedef Type& reference;
138 typedef const Type& const_reference;
139 typedef std::size_t size_type;
140 typedef std::ptrdiff_t difference_type;
141 typedef std::reverse_iterator<iterator> reverse_iterator;
142 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
143 typedef formatters::ArrayFormatter<Type,DynamicStorage>
Formatter;
146 typedef BluePrintFactory< Array<Type,DynamicStorage> > Factory;
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];
175 Array(
const Array<Type,DynamicStorage>& array) :
180 if ( array.size() != 0 ) {
182 std::copy(array.begin(),array.end(),begin());
206 Array(
const blueprints::ArrayBluePrint< T > &blueprint) : buffer_size(0), buffer(NULL) {
212 blueprint.implementApply(*
this);
220 if ( buffer != NULL ) {
240 containers::BoundedListInitialiser<value_type,iterator,DynamicStorage>
operator<<(
const Type &value) {
241 return containers::BoundedListInitialiser<value_type,iterator,DynamicStorage>(value,buffer,buffer_size);
244 void operator=(
const Array<Type,DynamicStorage>& array) {
245 if ( array.size() == 0 ) {
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];
395 Stencil< Array<Type,DynamicStorage> > stencil(
const unsigned int& start_index,
const unsigned int& n)
ecl_assert_throw_decl(StandardException) {
398 return Stencil< Array<Type,DynamicStorage> >(*
this, begin()+start_index, begin()+start_index+n);
438 reference at(size_type i)
throw(StandardException) {
439 if ( i>=buffer_size ) {
456 const_reference at(size_type i)
const throw(StandardException) {
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> > {
569 ConstantDynamicArray() {};
580 ConstantDynamicArray(
size_t size,
const Type &value ) :
585 virtual ~ConstantDynamicArray() {};
597 base_type instantiate() {
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.
ecl_geometry_PUBLIC void resize(Trajectory2D &trajectory, const int &size)
#define LOC
Stringify the line of code you are at.
OutputStream & operator<<(OutputStream &ostream, const Void void_object)
Output stream operator for Void objects.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
ecl_geometry_PUBLIC int size(const Trajectory2D &trajectory)
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.
#define ecl_compile_time_concept_check(Model)
Compile time concept checking assertion.
MatrixFormatter< Derived, Scalar > Formatter