aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Containers.h
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-03-23 00:11:58 +0100
committerShauren <shauren.trinity@gmail.com>2017-03-23 00:11:58 +0100
commitf097e341f5afcac2dd0ae9dbb265201c0de2a934 (patch)
tree6313a3f569c5b179deb675b2e836cb82d0859443 /src/common/Utilities/Containers.h
parent408d8768135dd8fb72150cc5ede9967cf57a728b (diff)
Core/Utilities: Rename RandomResizeList->RandomResize as it is no longer restricted to a list
* Also fix gcc build
Diffstat (limited to 'src/common/Utilities/Containers.h')
-rw-r--r--src/common/Utilities/Containers.h10
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()));