- Added method Vector::reverse().

This commit is contained in:
Andrey Syrokomsky 2013-12-08 14:34:00 +02:00
parent 65099897f4
commit dea6f0a24d

View file

@ -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>