Adds the invert() method to DVector.
This effectively allows invert() to be used on the following types: ByteArray, IntArray, RealArray, StringArray, Vector2Array, Vector3Array, ColorArray
This commit is contained in:
parent
f9d615ee87
commit
eb10c21a00
1 changed files with 13 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue