diff options
| author | Gau o fthe Veldt | 2016-07-17 16:43:10 -0700 |
|---|---|---|
| committer | Gau o fthe Veldt | 2016-07-23 12:52:41 -0700 |
| commit | 82d4cb5114a9d5f341dba84cbee51fcfe1504de6 (patch) | |
| tree | 372cb6449599b1a2ac9e743379b9058010e93a90 /core/dvector.h | |
| parent | 221cb58382ae34d4f91d9923fd979a328feabace (diff) | |
| download | godot-82d4cb5114a9d5f341dba84cbee51fcfe1504de6.tar.gz godot-82d4cb5114a9d5f341dba84cbee51fcfe1504de6.tar.zst godot-82d4cb5114a9d5f341dba84cbee51fcfe1504de6.zip | |
Diffstat (limited to 'core/dvector.h')
| -rw-r--r-- | core/dvector.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/dvector.h b/core/dvector.h index a5519ed60..9a5464161 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -262,6 +262,34 @@ public: w[bs+i]=r[i]; } + DVector<T> subarray(int p_from, int p_to) { + + if (p_from<0) { + p_from=size()+p_from; + } + if (p_to<0) { + p_to=size()+p_to; + } + if (p_from<0 || p_from>=size()) { + DVector<T>& aux=*((DVector<T>*)0); // nullreturn + ERR_FAIL_COND_V(p_from<0 || p_from>=size(),aux) + } + if (p_to<0 || p_to>=size()) { + DVector<T>& aux=*((DVector<T>*)0); // nullreturn + ERR_FAIL_COND_V(p_to<0 || p_to>=size(),aux) + } + + DVector<T> slice; + int span=1 + p_to - p_from; + slice.resize(span); + Read r = read(); + Write w = slice.write(); + for (int i=0; i<span; ++i) { + w[i] = r[p_from+i]; + } + + return slice; + } Error insert(int p_pos,const T& p_val) { |
