mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
tAlgorythm fed namespace T3D for better library interoperability. resulted in the need to specify usage in... a few places.
This commit is contained in:
parent
83449bbc06
commit
491a7dcfdd
20 changed files with 70 additions and 69 deletions
|
|
@ -23,40 +23,41 @@
|
|||
#ifndef _TALGORITHM_H_
|
||||
#define _TALGORITHM_H_
|
||||
|
||||
|
||||
/// Finds the first matching value within the container
|
||||
/// returning the the element or last if its not found.
|
||||
template <class Iterator, class Value>
|
||||
Iterator find(Iterator first, Iterator last, Value value)
|
||||
namespace T3D
|
||||
{
|
||||
while (first != last && *first != value)
|
||||
++first;
|
||||
return first;
|
||||
/// Finds the first matching value within the container
|
||||
/// returning the the element or last if its not found.
|
||||
template <class Iterator, class Value>
|
||||
Iterator find(Iterator first, Iterator last, Value value)
|
||||
{
|
||||
while (first != last && *first != value)
|
||||
++first;
|
||||
return first;
|
||||
}
|
||||
|
||||
/// Exchanges the values of the two elements.
|
||||
template <typename T>
|
||||
inline void swap(T &left, T &right)
|
||||
{
|
||||
T temp = right;
|
||||
right = left;
|
||||
left = temp;
|
||||
}
|
||||
|
||||
/// Steps thru the elements of an array calling detete for each.
|
||||
template <class Iterator, class Functor>
|
||||
void for_each(Iterator first, Iterator last, Functor func)
|
||||
{
|
||||
for (; first != last; first++)
|
||||
func(*first);
|
||||
}
|
||||
|
||||
/// Functor for deleting a pointer.
|
||||
/// @see for_each
|
||||
struct delete_pointer
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T *ptr) { delete ptr; }
|
||||
};
|
||||
}
|
||||
|
||||
/// Exchanges the values of the two elements.
|
||||
template <typename T>
|
||||
inline void swap( T &left, T &right )
|
||||
{
|
||||
T temp = right;
|
||||
right = left;
|
||||
left = temp;
|
||||
}
|
||||
|
||||
/// Steps thru the elements of an array calling detete for each.
|
||||
template <class Iterator, class Functor>
|
||||
void for_each( Iterator first, Iterator last, Functor func )
|
||||
{
|
||||
for ( ; first != last; first++ )
|
||||
func( *first );
|
||||
}
|
||||
|
||||
/// Functor for deleting a pointer.
|
||||
/// @see for_each
|
||||
struct delete_pointer
|
||||
{
|
||||
template <typename T>
|
||||
void operator()(T *ptr){ delete ptr;}
|
||||
};
|
||||
|
||||
#endif //_TALGORITHM_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue