tAlgorythm fed namespace T3D for better library interoperability. resulted in the need to specify usage in... a few places.

This commit is contained in:
Azaezel 2017-12-19 16:04:46 -06:00
parent 83449bbc06
commit 491a7dcfdd
20 changed files with 70 additions and 69 deletions

View file

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