63 for (
int k=1; k <=
m; k <<= 1) {n++;}
81 for (
int k=1; k <=
I.size(); k <<= 1){ n++;}
82 return Range(
I.begin(),
I.size() + n);
93template<
class Derived>
157 template<
class OtherDerived>
163 template<
class OtherDerived>
338template<
class Derived>
341template<
class Derived>
343 :
Base(
I), allocator_(Arrays::evalRangeCapacity(
I)) {}
345template<
class Derived>
348 , allocator_(Arrays::evalRangeCapacity(
I))
355template<
class Derived>
358 , allocator_(T.allocator(), ref)
364template<
class Derived>
365template<
class OtherDerived>
368 , allocator_(T.allocator(), ref)
375template<
class Derived>
376template<
class OtherDerived>
379 , allocator_(T.allocator(),
I, ref)
386template<
class Derived>
389 , allocator_(
A,
I, ref)
392template<
class Derived>
396template<
class Derived>
400 int inc =
beg - begin();
401 if (inc == 0)
return;
406 allocator_.shift(
beg);
409template<
class Derived>
413 if ( range() ==
I)
return this->asDerived();
416 shiftImpl(
I.begin());
418 const int inc =
I.end() - end();
420 if (inc > 0) pushBack(inc);
422 return this->asDerived();
425template<
class Derived>
432 allocator_.realloc(
Range(begin(), size));
435template<
class Derived>
442template<
class Derived>
445 if (this->asPtrDerived() == &T)
return;
446 if (!isRef()) { freeMem();}
447 allocator_.move(T.allocator_);
451template<
class Derived>
454#ifdef STK_ARRAYS_VERY_VERBOSE
455 stk_cout <<
_T(
"Entering IArray1D<Derived>::pushBack(") << n <<
_T(
")\n");
458 if (n <= 0)
return this->asDerived();
461 if (this->empty()) { initialize(
RowRange(begin(), n));}
462 else { insertElt(end(), n);}
463 return this->asDerived();
466template<
class Derived>
470 if (n <= 0 || isFixedSize_)
return this->asDerived();
474 if (size() <= 0) this->freeMem();
475 return this->asDerived();
478template<
class Derived>
481#ifdef STK_DEBUG_ARRAY2D
483 stk_cout <<
_T(
"Deleting pos=") << pos <<
_T(
", n=") << n <<
_T(
"\n");
488 if (n<=0)
return this->asDerived();
491#ifdef STK_BOUNDS_CHECK
501 allocator_.memmove(pos,
_R(pos+n, end()-1));
504 if (size() <= 0) this->freeMem();
505 return this->asDerived();
508template<
class Derived>
512 if (n <= 0 )
return this->asDerived();
514#ifdef STK_BOUNDS_CHECK
522 if ( (capacity() < size()+n) && !isFixedSize_ )
531 try { allocate(range);}
538 setRange(
Taux.range());
540 allocator_.memcpy(
Taux.begin(),
Taux.allocator_,
Range(
Taux.begin(), pos - begin()) );
541 allocator_.memcpy(pos+n,
Taux.allocator_,
Range(pos, end()-pos) );
546 { allocator_.memmove(pos+n,
Range(pos, end() - pos));}
548 { allocator_.memmove(pos+n,
Range(pos, end() - pos - n));}
551 return this->asDerived();
558template<
class Derived>
562 allocator_.setValue(pos,
v);
563 return this->asDerived();
566template<
class Derived>
569 insertElt(
I.begin(),
I.size());
570 for (
int i=
I.begin();
i<
I.end();
i++) allocator_.setValue(
i,
v);
571 return this->asDerived();
574template<
class Derived>
577 insert(
Range(begin(), 1),
v);
578 return this->asDerived();
581template<
class Derived>
585 allocator_.setValue(this->lastIdx(),
v);
586 return this->asDerived();
589template<
class Derived>
592#ifdef STK_BOUNDS_CHECK
601template<
class Derived>
608template<
class Derived>
612 if (&allocator_ == &(
src.allocator())) {
return this->asDerived();}
614 if ( size() !=
src.size() ) { this->resize(
src.range());}
615 allocator_.memcpy(begin(),
src.allocator_,
src.range());
616 return this->asDerived();
623template<
class Derived>
626#ifdef STK_BOUNDS_CHECK
639template<
class Derived>
642 allocator_.assign(range(), value);
643 return this->asDerived();
646template<
class Derived>
650 allocator_.setRef(
false);
654template<
class Derived>
668template<
class Derived>
In this file we define the main traits class we use for the STK++ Containers.
In this file we define utilities functions and enum for the Array classes.
In this file we implement the BiDirectionalIterator class.
In this file we define and implement the DenseRandomIterator and ConstDenseRandomIterator classes.
This is an internal header file, included by other Containers library headers.
in this file we define the interface class ITContainer1D.
#define STKRUNTIME_ERROR_1ARG(Where, Arg, Error)
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
#define STKRUNTIME_ERROR_2ARG(Where, Arg1, Arg2, Error)
In this file we define the class MemAllocator.
#define _R(first, last)
Utility macro that can be used in a similar way that first:last.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
This file include all the header files of the project STKernel.
Sdk class for all library Exceptions.
template one dimensional Array.
Derived & popBack(int n=1)
Delete last elts of the container.
Derived & setValue(Type const &value)
set a value to this container.
void setValue(int pos, TypeConst value)
Write a value at a given position.
Derived & assign(IArray1D const &src)
overwrite this with src.
Derived & insert(Range const &I, Type const &v)
STL compatibility: Insert element v in the range I of the Array.
Derived & erase(int pos, int n=1)
Delete n elements at the pos index to the container.
hidden::Traits< Derived >::Iterator Iterator
hidden::Traits< Derived >::ConstReverseIterator ConstReverseIterator
hidden::Traits< Derived >::ColRange ColRange
RowRange const & rows() const
Type & elt1Impl(int pos)
access to an element
void memmove(int pos1, int pos2, int n)
Copy n elements from pos2 to pos1, guaranteeing correct behavior for overlapping.
IArray1D(Range const &I)
constructor with a specified Range.
IArray1D(Range const &I, Type const &v)
Misc constructor with first and last, initialization with a constant.
void swap(int pos1, int pos2)
Swapping the pos1 elt and the pos2 elt.
void exchange(IArray1D &T)
exchange this Container with T.
ITContainer1D< Derived > Base
IArray1D(Allocator const &A, Range const &I, bool ref)
Wrapper constructor.
TypeConst elt1Impl(int pos) const
access to a constant element
IArray1D(IArray1D< OtherDerived > const &T, bool ref)
Copy constructor.
void setRef(bool ref) const
Modify the state of the container: this become a reference (if ref is true) or the owner of the data ...
void allocate(RowRange const &I)
function for memory allocation.
Derived & pushBack(int n=1)
Add n Elements to the end of the container.
void freeMem()
Method for memory deallocation.
hidden::Traits< Derived >::ReverseIterator ReverseIterator
Derived & resizeImpl(Range const &I)
Resize the container.
void reserve(int size)
reserve internal memory for at least size elements.
void clear()
Clear the object.
hidden::Traits< Derived >::Type Type
hidden::Traits< Derived >::Allocator Allocator
hidden::Traits< Derived >::TypeConst TypeConst
void initialize(RowRange const &I)
function for memory allocation and initialization.
Derived & push_back(Type const &v)
STL compatibility: append an element v.
void shiftImpl(int beg=baseIdx)
New beginning index for the object.
hidden::Traits< Derived >::RowRange RowRange
~IArray1D()
destructor: allocated memory is liberated by MemAllocator class.
Derived & insert(int pos, Type const &v)
STL compatibility: Insert element v at position pos of the Array.
Derived & insertElt(int pos, int n=1)
Insert n elements at the position pos of the container.
IArray1D(IArray1D const &T, bool ref)
Copy constructor.
Derived & push_front(Type const &v)
STL compatibility: push front an element.
IArray1D(IArray1D< OtherDerived > const &T, RowRange const &I, bool ref)
copy constructor.
RowRange const & range() const
hidden::Traits< Derived >::ConstIterator ConstIterator
IArray1D()
Default constructor.
void move(Derived const &T)
move T to this.
Allocator const & allocator() const
String const & error() const
get the last error message.
Interface base class for homogeneous 1D containers.
void incRange(int n=1)
increment the range of the container (can be negative).
void setRange(RowRange const &I=RowRange())
Set range of the rows of the container.
void incLast(int n=1)
increment the end of the container (can be negative).
RowRange const & range() const
void decLast(int n=1)
decrement the end of the container.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
int evalSizeCapacity(int m)
TRange< Size_ > evalRangeCapacity(TRange< Size_ > const &I)
Range incLast(TRange< SizeI_ > const &I)
if I=a:b, return a:b+1
Range decLast(TRange< SizeI_ > const &I)
if I=a:b, return a:b-1
const int UnknownSize
This value means that an integer is not known at compile-time, and that instead the value is stored i...
const int baseIdx
base index of the containers created in STK++.
The namespace STK is the main domain space of the Statistical ToolKit project.
TRange< UnknownSize > Range