mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Array<int> ia(n); ia.Range(2, END-1)
This commit is contained in:
parent
7b62f39460
commit
1f45601387
@ -213,6 +213,20 @@ namespace ngcore
|
||||
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;
|
||||
|
||||
|
||||
@ -560,6 +574,12 @@ namespace ngcore
|
||||
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
|
||||
NETGEN_INLINE FlatArray<T> Range (T_Range<size_t> range) const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user