diff options
author | kjohnson0451 <kjohnson0451@gmail.com> | 2016-05-16 13:06:41 -0400 |
---|---|---|
committer | kjohnson0451 <kjohnson0451@gmail.com> | 2016-05-16 13:06:41 -0400 |
commit | eb10c21a00b871ed9ed2f1704831a52cbe4ccdfe (patch) | |
tree | b41c127913ed76693a4b5bfb6cea1d81b3fc22df | |
parent | f9d615ee87ac27fa5fa26f91738b5267ecc7b40e (diff) |
Adds the invert() method to DVector.
This effectively allows invert() to be used on the following types:
ByteArray, IntArray, RealArray, StringArray, Vector2Array, Vector3Array, ColorArray
-rw-r--r-- | core/dvector.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/dvector.h b/core/dvector.h index fbb1fc4824..a5519ed604 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -285,6 +285,7 @@ public: Error resize(int p_size); + void invert(); void operator=(const DVector& p_dvector) { reference(p_dvector); } DVector() {} @@ -424,6 +425,18 @@ Error DVector<T>::resize(int p_size) { return OK; } +template<class T> +void DVector<T>::invert() { + T temp; + Write w = write(); + int s = size(); + int half_s = s/2; + for(int i=0;i<half_s;i++) { + temp = w[i]; + w[i] = w[s-i-1]; + w[s-i-1] = temp; + } +} #endif |