mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #553 from signmotion/add-vector-reverse
Added method Vector::reverse().
This commit is contained in:
commit
32abd2c149
|
|
@ -28,6 +28,7 @@
|
|||
#ifndef _PLATFORM_H_
|
||||
#include "platform/platform.h"
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper definitions for the vector class.
|
||||
|
|
@ -181,6 +182,9 @@ class Vector
|
|||
///
|
||||
void merge( const T *addr, U32 count );
|
||||
|
||||
// Reverses the order of elements.
|
||||
void reverse();
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
|
@ -760,6 +764,12 @@ template<class T> inline void Vector<T>::merge( const T *addr, U32 count )
|
|||
mElementCount = newSize;
|
||||
}
|
||||
|
||||
template<class T> inline void Vector<T>::reverse()
|
||||
{
|
||||
for (U32 i = 0, j = size(); (i != j) && (i != --j); ++i)
|
||||
std::swap( mArray[ i ], mArray[ j ] );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Template for vectors of pointers.
|
||||
template <class T>
|
||||
|
|
|
|||
Loading…
Reference in a new issue