STK++ 0.9.13
|
Index sub-vector region: Specialization when the size is unknown. More...
#include <STK_Range.h>
Public Types | |
typedef RangeBase< TRange< UnknownSize > > | Base |
Public Member Functions | |
TRange (int size=0) | |
constructor. | |
TRange (int first, int size) | |
Complete constructor. | |
TRange (int first, int last, bool junk) | |
Complete constructor. | |
TRange (TRange const &I) | |
Copy constructor. | |
template<int OtherSize_> | |
TRange (TRange< OtherSize_ > const &I) | |
Copy constructor. | |
~TRange () | |
destructor. | |
int | end () const |
get the ending index of the TRange. | |
int | size () const |
get the size of the TRange (the number of elements). | |
bool | empty () const |
check if the range is empty or not. | |
int | lastIdx () const |
get the last index of the TRange. | |
TRange & | shift (int first) |
Shift the TRange giving the first element: the size is not modified. | |
TRange & | inc (int inc=1) |
create the TRange [begin_+inc, end_+inc_). | |
TRange & | dec (int dec=1) |
create the TRange [begin_+inc, end_). | |
TRange & | incFirst (int inc=1) |
create the TRange [begin_-dec, end_-dec) | |
TRange & | decFirst (int dec=1) |
create the TRange [begin_-dec, end_) | |
TRange & | incEnd (int inc=1) |
create the TRange [begin_, end_+inc) | |
TRange & | decEnd (int dec=1) |
create the TRange [begin_, end_-dec) | |
TRange & | incLast (int inc=1) |
create the TRange [begin_, end_+inc) | |
TRange & | decLast (int dec=1) |
create the TRange [begin_, end_-dec) | |
template<int OtherSize_> | |
TRange & | sup (TRange< OtherSize_ > const &I) |
Take the lowest value of begin_ and I.begin_ for begin_ and the largest value of end_ and I.end_ for end_. | |
template<int OtherSize_> | |
TRange & | inf (TRange< OtherSize_ > const &I) |
Take the largest value of begin_ and I.begin_ for begin_ and the lowest value of end_ and I.end_ for end_. | |
![]() | |
~RangeBase () | |
destructor. | |
int | begin () const |
get the first index of the TRange. | |
bool | isIn (TRange< OtherSize_ > const &I) const |
check if this TRange in include in an other TRange | |
bool | isContaining (TRange< OtherSize_ > const &I) const |
check if the TRange I is include in the this TRange | |
bool | isContaining (int i) const |
Return true if i is in this TRange. | |
TRange< UnknownSize > & | operator+= (int i) |
shift range a:b becomes (a+i):(b+i) | |
TRange< UnknownSize > & | operator-= (int i) |
shift range a:b becomes (a+i):(b+i) | |
bool | operator== (TRange< OtherSize_ > const &I) const |
compare this range with range I | |
bool | operator!= (TRange< OtherSize_ > const &I) const |
compare this range with range I | |
![]() | |
Derived & | asDerived () |
static cast : return a reference of this with a cast to the derived class. | |
Derived const & | asDerived () const |
static cast : return a const reference of this with a cast to the derived class. | |
Derived * | asPtrDerived () |
static cast : return a ptr on a Derived of this with a cast to the derived class. | |
Derived const * | asPtrDerived () const |
static cast : return a ptr on a constant Derived of this with a cast to the derived class. | |
Derived * | clone () const |
create a leaf using the copy constructor of the Derived class. | |
Derived * | clone (bool isRef) const |
create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not. | |
Private Attributes | |
int | size_ |
theoretic Dimension size_ = end_- begin_ | |
Friends | |
istream & | operator>> (istream &is, Range &I) |
Read a Range in the form first:last (MATLAB-like form) from an input stream. | |
Additional Inherited Members | |
![]() | |
RangeBase () | |
Default constructor. | |
RangeBase (int begin) | |
constructor. | |
RangeBase (RangeBase const &I) | |
Copy constructor. | |
RangeBase (RangeBase< OtherDerived > const &I) | |
Copy constructor. | |
![]() | |
IRecursiveTemplate () | |
constructor. | |
~IRecursiveTemplate () | |
destructor. | |
![]() | |
int | begin_ |
First index. | |
Index sub-vector region: Specialization when the size is unknown.
A Range is an ordered pair [first,last] denoting a sub-vector region, similar to a Fortran 90 or Matlab colon notation. For example :
overwrite the elements (2, 3, 4) of A by the elements (0, 1, 2) of B. There is no stride argument, only contiguous regions are allowed.
Definition at line 264 of file STK_Range.h.
typedef RangeBase<TRange<UnknownSize> > STK::TRange< UnknownSize >::Base |
Definition at line 267 of file STK_Range.h.
|
inline |
constructor.
By default the first index is defined by the firstIdx macro.
size | size of the sub-region |
Definition at line 273 of file STK_Range.h.
|
inline |
Complete constructor.
Give the beginning and the size of the sub-region.
first,size | beginning and size of the range |
Definition at line 277 of file STK_Range.h.
|
inline |
Complete constructor.
Give the first and last index of the sub-region.
first,last | first and last indexes of the sub-region |
junk | allow to use the constructor (begin:last) rather than (begin,size) |
Definition at line 282 of file STK_Range.h.
|
inline |
Copy constructor.
Create a copy of an existing TRange.
I | range to copy |
Definition at line 287 of file STK_Range.h.
|
inline |
Copy constructor.
Create a copy of an existing TRange.
I | range to copy |
Definition at line 293 of file STK_Range.h.
|
inline |
|
inline |
create the TRange [begin_+inc, end_).
dec | the decrement to apply |
Definition at line 325 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and dec().
Referenced by dec().
|
inline |
create the TRange [begin_, end_-dec)
dec | the decrement to apply |
Definition at line 343 of file STK_Range.h.
References STK::TRange< Size_ >::dec().
|
inline |
create the TRange [begin_-dec, end_)
dec | the decrement to apply |
Definition at line 334 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::dec().
|
inline |
create the TRange [begin_, end_-dec)
dec | the decrement to apply |
Definition at line 353 of file STK_Range.h.
References STK::TRange< Size_ >::dec().
|
inline |
check if the range is empty or not.
true
if size <=0, false
otherwise Definition at line 307 of file STK_Range.h.
|
inline |
get the ending index of the TRange.
Definition at line 299 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_.
Referenced by STK::MemSAllocator1D< Type_, NzMax_ >::end(), STK::MemSAllocator1D< Type_, NzMax_ >::memmove(), STK::Arrays::SumOp< Lhs, Rhs >::operator()(), STK::Arrays::DifferenceOp< Lhs, Rhs >::operator()(), STK::Arrays::Product< Lhs, Rhs >::operator()(), STK::Arrays::DivOp< Lhs, Rhs >::operator()(), STK::hidden::MemHandler< Type_, UnknownSize >::realloc(), and STK::hidden::ProductDispatcher< Lhs, Rhs, Result, lhsStructure_, RhsStructure_ >::run().
|
inline |
create the TRange [begin_+inc, end_+inc_).
inc | the increment to apply |
Definition at line 321 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and inc().
Referenced by inc().
|
inline |
create the TRange [begin_, end_+inc)
inc | the increment to apply |
Definition at line 339 of file STK_Range.h.
References STK::TRange< Size_ >::inc().
|
inline |
create the TRange [begin_-dec, end_-dec)
inc | the increment to apply to begin_ |
Definition at line 330 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::inc().
|
inline |
create the TRange [begin_, end_+inc)
inc | the increment to apply |
Definition at line 349 of file STK_Range.h.
References STK::TRange< Size_ >::inc().
Referenced by STK::IArray2D< Derived >::merge(), and STK::List1D< Type_ >::merge().
|
inline |
Take the largest value of begin_ and I.begin_ for begin_ and the lowest value of end_ and I.end_ for end_.
I | the index to apply |
Definition at line 371 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::end().
|
inline |
get the last index of the TRange.
Definition at line 313 of file STK_Range.h.
References STK::TRange< Size_ >::end().
Referenced by STK::MemSAllocator1D< Type_, NzMax_ >::memmove().
|
inline |
Shift the TRange giving the first element: the size is not modified.
first | new value of the first element. |
Definition at line 317 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::inc().
|
inline |
get the size of the TRange (the number of elements).
Definition at line 303 of file STK_Range.h.
Referenced by STK::Categorical_pk< Array >::computeNbFreeParameters(), STK::CvHandler::CvHandler(), STK::hidden::MemHandler< Type_, UnknownSize >::malloc(), STK::MemSAllocator1D< Type_, NzMax_ >::memmove(), STK::MemAllocator< Type_, Size_ >::realloc(), STK::PartitionHandler::setData(), and STK::MemSAllocator1D< Type_, NzMax_ >::size().
|
inline |
Take the lowest value of begin_ and I.begin_ for begin_ and the largest value of end_ and I.end_ for end_.
I | the index to apply |
Definition at line 360 of file STK_Range.h.
References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::end().
Read a Range in the form first:last (MATLAB-like form) from an input stream.
The input stream can also be a number (say n). In this case the range will be n:n. If the range cannot be read the method return a NA value
is | the input stream |
I | the range to set |
Definition at line 431 of file STK_Range.h.
|
private |
theoretic Dimension size_ = end_- begin_
Definition at line 389 of file STK_Range.h.