mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-11 21:50:34 +05:00
Array<int> ia(n); ia.Range(2, END-1)
This commit is contained in:
parent
7b62f39460
commit
1f45601387
@ -212,6 +212,20 @@ namespace ngcore
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr T IndexBASE () { return T(0); }
|
constexpr T IndexBASE () { return T(0); }
|
||||||
|
|
||||||
|
|
||||||
|
class IndexFromEnd
|
||||||
|
{
|
||||||
|
ptrdiff_t i;
|
||||||
|
public:
|
||||||
|
constexpr IndexFromEnd (ptrdiff_t ai) : i(ai) { }
|
||||||
|
IndexFromEnd operator+ (ptrdiff_t inc) const { return i+inc; }
|
||||||
|
IndexFromEnd operator- (ptrdiff_t dec) const { return i-dec; }
|
||||||
|
// operator ptrdiff_t () const { return i; }
|
||||||
|
ptrdiff_t Value() const { return i; }
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr IndexFromEnd END(0);
|
||||||
|
|
||||||
|
|
||||||
template <class T, class IndexType = size_t> class FlatArray;
|
template <class T, class IndexType = size_t> class FlatArray;
|
||||||
|
|
||||||
@ -560,6 +574,12 @@ namespace ngcore
|
|||||||
return FlatArray<T> (end-start, data+start);
|
return FlatArray<T> (end-start, data+start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// takes range starting from position start of end-start elements
|
||||||
|
NETGEN_INLINE FlatArray<T> Range (size_t start, IndexFromEnd indend) const
|
||||||
|
{
|
||||||
|
return this->Range(start, size_t(Size()+indend.Value()));
|
||||||
|
}
|
||||||
|
|
||||||
/// takes range starting from position start of end-start elements
|
/// takes range starting from position start of end-start elements
|
||||||
NETGEN_INLINE FlatArray<T> Range (T_Range<size_t> range) const
|
NETGEN_INLINE FlatArray<T> Range (T_Range<size_t> range) const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user