Class for performing a radix sort (fast comparison-less sort based on byte value) on various standard STL containers.
More...
#include <OgreRadixSort.h>
|
| RadixSort () |
|
| ~RadixSort () |
|
template<class TFunction > |
void | sort (ContainerIter dbegin, ContainerIter dend, TFunction func) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
|
|
template<class TFunction > |
void | sort (TContainer &container, TFunction func) |
| Main sort function. More...
|
|
template<class TContainer, class TContainerValueType, typename TCompValueType>
class Ogre::RadixSort< TContainer, TContainerValueType, TCompValueType >
Class for performing a radix sort (fast comparison-less sort based on byte value) on various standard STL containers.
- This is a template class to allow it to deal with a variety of containers, and a variety of value types to sort on. In addition to providing the container and value type on construction, you also need to supply a functor object which will retrieve the value to compare on for each item in the list. For example, if you had an std::vector of by-value instances of an object of class 'Bibble', and you wanted to sort on Bibble::getDoobrie(), you'd have to firstly create a functor like this:
struct BibbleSortFunctor
{
float operator()(const Bibble& val) const
{
return val.getDoobrie();
}
}
Then, you need to declare a RadixSort class which names the container type, the value type in the container, and the type of the value you want to sort by. You can then call the sort function. E.g. RadixSort<BibbleList, Bibble, float> radixSorter;
BibbleSortFunctor functor;
radixSorter.sort(myBibbleList, functor);
You should try to reuse RadixSort instances, since repeated allocation of the internal storage is then avoided.
- Note
- Radix sorting is often associated with just unsigned integer values. Our implementation can handle both unsigned and signed integers, as well as floats (which are often not supported by other radix sorters). doubles are not supported; you will need to implement your functor object to convert to float if you wish to use this sort routine.
◆ ContainerIter
template<class TContainer , class TContainerValueType , typename TCompValueType >
◆ RadixSort()
template<class TContainer , class TContainerValueType , typename TCompValueType >
◆ ~RadixSort()
template<class TContainer , class TContainerValueType , typename TCompValueType >
◆ sort() [1/2]
template<class TContainer , class TContainerValueType , typename TCompValueType >
template<class TFunction >
void Ogre::RadixSort< TContainer, TContainerValueType, TCompValueType >::sort |
( |
TContainer & |
container, |
|
|
TFunction |
func |
|
) |
| |
|
inline |
◆ sort() [2/2]
template<class TContainer , class TContainerValueType , typename TCompValueType >
template<class TFunction >
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The documentation for this class was generated from the following file: