diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-03-23 00:11:58 +0100 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-06-03 02:27:48 -0300 |
commit | abac1b34bcb84d65ef857076321af3acd22a3c9b (patch) | |
tree | 3b698b17e9233a612faf44777d7b8d4402cb18f2 /src/common/Utilities/Containers.h | |
parent | ff39c27104634c9f1d37a0625eb78461e34c77a0 (diff) |
Core/Utilities: Rename RandomResizeList->RandomResize as it is no longer restricted to a list
* Also fix gcc build
(cherry picked from commit f097e341f5afcac2dd0ae9dbb265201c0de2a934)
Diffstat (limited to 'src/common/Utilities/Containers.h')
-rw-r--r-- | src/common/Utilities/Containers.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/Utilities/Containers.h b/src/common/Utilities/Containers.h index dc0f4d7c244..0a437b0e4d8 100644 --- a/src/common/Utilities/Containers.h +++ b/src/common/Utilities/Containers.h @@ -54,7 +54,7 @@ namespace Trinity } template<class C> - void RandomResizeList(C& container, std::size_t requestedSize) + void RandomResize(C& container, std::size_t requestedSize) { uint32 currentSize = uint32(Size(container)); while (currentSize > requestedSize) @@ -67,7 +67,7 @@ namespace Trinity } template<class C, class Predicate> - void RandomResizeList(C& container, Predicate&& predicate, std::size_t requestedSize) + void RandomResize(C& container, Predicate&& predicate, std::size_t requestedSize) { //! First use predicate filter C containerCopy; @@ -75,7 +75,7 @@ namespace Trinity if (requestedSize) { std::copy_if(std::begin(container), std::end(container), std::inserter(containerCopy, std::end(containerCopy)), predicate); - RandomResizeList(containerCopy, requestedSize); + RandomResize(containerCopy, requestedSize); } container = std::move(containerCopy); @@ -87,7 +87,7 @@ namespace Trinity * Note: container cannot be empty */ template<class C> - inline auto SelectRandomContainerElement(C const& container) -> decltype(*std::begin(container)) const& + inline auto SelectRandomContainerElement(C const& container) -> typename std::add_const<decltype(*std::begin(container))>::type& { auto it = std::begin(container); std::advance(it, urand(0, uint32(Size(container)) - 1)); @@ -104,7 +104,7 @@ namespace Trinity * Note: container cannot be empty */ template<class C> - auto SelectRandomWeightedContainerElement(C const& container, std::vector<double> weights) -> decltype(std::begin(container)) + inline auto SelectRandomWeightedContainerElement(C const& container, std::vector<double> weights) -> decltype(std::begin(container)) { auto it = std::begin(container); std::advance(it, urandweighted(weights.size(), weights.data())); |