|
Core Library
1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
|
Templated static class to perform a bucket sort. More...
#include <GenericSorting.h>
Public Types | |
| using | item_compare = Pred |
| Public typedef for predicate. | |
| using | bucket_definitions = std::vector< std::pair< T, T > > |
| Public typedef for bucket definitions. | |
| using | bucket_values = std::vector< std::list< T > > |
| Public typedef for bucket values. | |
Static Public Member Functions | |
| template<typename TIterator > | |
| static void | Sort (TIterator begin, TIterator end, const bucket_definitions &bucketDefinitions, bucket_values &bucketValues) |
| In-place static sort function. More... | |
| template<typename TIterator > | |
| static void | Sort (TIterator begin, TIterator end, const bucket_definitions &bucketDefinitions) |
| Static sort function. More... | |
Static Private Member Functions | |
| static void | CheckBucketsSize (const bucket_definitions &bucketDefinitions, bucket_values &bucketValues) |
| Static function to check bucket values collection size. More... | |
| static size_t | GetBucketIndex (const T &value, const bucket_definitions &bucketDefinitions) |
| Static compute the correct bucket index for a given item. More... | |
| template<typename TIterator > | |
| static void | PutIntoBuckets (TIterator begin, TIterator end, const bucket_definitions &bucketDefinitions, bucket_values &bucketValues) |
| Static to put the items in to the correct buckets. More... | |
| template<typename TIterator > | |
| static void | WriteBackBuckets (TIterator begin, const bucket_values &bucketValues) |
| Static to move the items from the buckets back into the original collection. More... | |
| template<typename TIterator > | |
| static void | SortResult (TIterator begin, TIterator end) |
| Static method to perform a final sort on the collection. More... | |
Templated static class to perform a bucket sort.
Template args are T, the type of value to be sorted, and Pred, the comparison functor to compare items of type T. The default comparison predicate is std::less<T>.
|
inlinestaticprivate |
Static function to check bucket values collection size.
| [in] | bucketDefinitions | - The definition of the ranges of the different buckets, e.g. the min and max values per bucket. |
| [in] | bucketValues | - The bucket values collection. |
This function compares the size of the bucket values collection to that of the bucket definitions collection and resizes the bucket value collection if required.
|
inlinestaticprivate |
Static compute the correct bucket index for a given item.
| [in] | value | - The item to put in to a bucket. |
| [in] | bucketDefinitions | - The definition of the ranges of the different buckets, e.g. the min and max values per bucket. |
This function iterates over the buckets until it finds the correct one to hold the given item.
|
inlinestaticprivate |
Static to put the items in to the correct buckets.
| [in] | begin | - The begining of the collection to sort. |
| [in] | end | - The end of the collection to sort (in STL fashion this is the item just after the last otem to be sorted). |
| [in] | bucketDefinitions | - The definition of the ranges of the different buckets, e.g. the min and max values per bucket. |
| [out] | bucketValues | - The collection of buckets containing the values for each bucket range. |
This function builds up the buckets with the correct items.
|
inlinestatic |
In-place static sort function.
| [in] | begin | - The begining of the collection to sort. |
| [in] | end | - The end of the collection to sort (in STL fashion this is the item just after the last item to be sorted). |
| [in] | bucketDefinitions | - The definition of the ranges of the different buckets, e.g. the min and max values per bucket. |
| [out] | bucketValues | - The collection of buckets containing the values for each bucket range. |
This function sorts a collection (vector, list etc) of items of type T between a begin and end iterator. This version can be used when the user is interested in gaining access to the intermediate collection of buckets containing the partitioned values.
|
inlinestatic |
Static sort function.
| [in] | begin | - The begining of the collection to sort. |
| [in] | end | - The end of the collection to sort (in STL fashion this is the item just after the last item to be sorted). |
| [in] | bucketDefinitions | - The definition of the ranges of the different buckets, e.g. the min and max values per bucket. |
This function sorts a collection (vector, list etc) of items of type T between a begin and end iterator. This version can be used when the user is only interested in the final result.
|
inlinestaticprivate |
Static method to perform a final sort on the collection.
| [in] | begin | - The beginning of the collection to sort. |
| [in] | end | - The end of the collection to sort (in STL fashion this is the item just after the last otem to be sorted). |
This function performs an insertion sort on the modified bucket ordered collection to obtain the sorted result.
|
inlinestaticprivate |
Static to move the items from the buckets back into the original collection.
| [in] | begin | - The begining of the collection to sort. |
| [in] | bucketValues | - The collection of buckets containing the values for each bucket range. |
This function moves each bucket item, in bucket order, back into the original collection, overwriting the original collection. After calling this method the collection still needs a final sort performed.