diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-07 13:45:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-07 14:21:16 +0100 |
commit | fb6d3b883bfcd8de73d4426cc68ed6a7cc9e773a (patch) | |
tree | c136bf85c72aba4a8273c6e666775b4819c4c5cd | |
parent | 75a23240d6ac090305f18ca93094ce2739eb8646 (diff) |
disambiguate uniform_int_distribution
Change-Id: Ifa0c1b1983d1cc7f22d55b15dee88b7f709dbcf8
-rw-r--r-- | basegfx/test/boxclipper.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/misc/random.cxx | 8 | ||||
-rw-r--r-- | cui/source/customize/cfg.cxx | 2 | ||||
-rw-r--r-- | include/comphelper/random.hxx | 8 | ||||
-rw-r--r-- | sc/source/core/tool/interpr3.cxx | 2 | ||||
-rw-r--r-- | sd/source/core/CustomAnimationPreset.cxx | 6 | ||||
-rw-r--r-- | slideshow/source/inc/tools.hxx | 2 | ||||
-rw-r--r-- | sw/qa/core/uwriter.cxx | 2 |
8 files changed, 12 insertions, 20 deletions
diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx index 54e5e96071ac..696e86c622e9 100644 --- a/basegfx/test/boxclipper.cxx +++ b/basegfx/test/boxclipper.cxx @@ -48,7 +48,7 @@ double getRandomOrdinal( const ::std::size_t n ) { // use this one when displaying polygons in OOo, which still sucks // great rocks when trying to import non-integer svg:d attributes - return comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), n-1); + return comphelper::rng::uniform_size_distribution(0, n-1); } inline bool compare(const B2DPoint& left, const B2DPoint& right) diff --git a/comphelper/source/misc/random.cxx b/comphelper/source/misc/random.cxx index bcdd8e6c7198..4da4acb84d7a 100644 --- a/comphelper/source/misc/random.cxx +++ b/comphelper/source/misc/random.cxx @@ -60,23 +60,19 @@ int uniform_int_distribution(int a, int b) } // uniform ints [a,b] distribution -unsigned int uniform_int_distribution(unsigned int a, unsigned int b) +unsigned int uniform_uint_distribution(unsigned int a, unsigned int b) { boost::random::uniform_int_distribution<unsigned int> dist(a, b); return dist(theRandomNumberGenerator::get().global_rng); } -#if SAL_TYPES_SIZEOFLONG == 8 - // uniform size_t [a,b] distribution -size_t uniform_int_distribution(size_t a, size_t b) +size_t uniform_size_distribution(size_t a, size_t b) { boost::random::uniform_int_distribution<size_t> dist(a, b); return dist(theRandomNumberGenerator::get().global_rng); } -#endif - // uniform size_t [a,b) distribution double uniform_real_distribution(double a, double b) { diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index a8adf2f43ca0..038bb0e517c2 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -298,7 +298,7 @@ generateCustomName( sal_uInt32 generateRandomValue() { - return comphelper::rng::uniform_int_distribution(static_cast<unsigned int>(0), std::numeric_limits<unsigned int>::max()); + return comphelper::rng::uniform_uint_distribution(0, std::numeric_limits<unsigned int>::max()); } OUString diff --git a/include/comphelper/random.hxx b/include/comphelper/random.hxx index 7c149fbe8cd9..3b1fabb3f7aa 100644 --- a/include/comphelper/random.hxx +++ b/include/comphelper/random.hxx @@ -32,14 +32,10 @@ COMPHELPER_DLLPUBLIC double uniform_real_distribution(double a = 0.0, double b = COMPHELPER_DLLPUBLIC int uniform_int_distribution(int a, int b); /// uniform distribution in [a,b] -COMPHELPER_DLLPUBLIC unsigned int uniform_int_distribution(unsigned int a, unsigned int b); - -#if SAL_TYPES_SIZEOFLONG == 8 +COMPHELPER_DLLPUBLIC unsigned int uniform_uint_distribution(unsigned int a, unsigned int b); /// uniform distribution in [a,b] -COMPHELPER_DLLPUBLIC size_t uniform_int_distribution(size_t a, size_t b); - -#endif +COMPHELPER_DLLPUBLIC size_t uniform_size_distribution(size_t a, size_t b); } // namespace diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx index 7b97d598ff2b..5e0af0df2825 100644 --- a/sc/source/core/tool/interpr3.cxx +++ b/sc/source/core/tool/interpr3.cxx @@ -3820,7 +3820,7 @@ void ScInterpreter::QuickSort( vector<double>& rSortArray, vector<long>* pIndexO size_t nValCount = rSortArray.size(); for (size_t i = 0; (i + 4) <= nValCount-1; i += 4) { - size_t nInd = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), nValCount-2); + size_t nInd = comphelper::rng::uniform_size_distribution(0, nValCount-2); ::std::swap( rSortArray[i], rSortArray[nInd]); if (pIndexOrder) ::std::swap( pIndexOrder->at(i), pIndexOrder->at(nInd)); diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 09ba6a5e5820..00216a7c4f7b 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -577,12 +577,12 @@ Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 n if( pCategoryList && pCategoryList->size() ) { - sal_Int32 nCategory = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), pCategoryList->size()-1); + sal_Int32 nCategory = comphelper::rng::uniform_size_distribution(0, pCategoryList->size()-1); PresetCategoryPtr pCategory = (*pCategoryList)[nCategory]; if( pCategory.get() && !pCategory->maEffects.empty() ) { - sal_Int32 nDescriptor = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), pCategory->maEffects.size()-1); + sal_Int32 nDescriptor = comphelper::rng::uniform_size_distribution(0, pCategory->maEffects.size()-1); CustomAnimationPresetPtr pPreset = pCategory->maEffects[nDescriptor]; if( pPreset.get() ) { @@ -591,7 +591,7 @@ Reference< XAnimationNode > CustomAnimationPresets::getRandomPreset( sal_Int16 n OUString aSubType; if( !aSubTypes.empty() ) { - size_t nSubType = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), aSubTypes.size()-1); + size_t nSubType = comphelper::rng::uniform_size_distribution(0, aSubTypes.size()-1); aSubType = aSubTypes[nSubType]; } xNode = pPreset->create( aSubType ); diff --git a/slideshow/source/inc/tools.hxx b/slideshow/source/inc/tools.hxx index 682530f3bbc0..e1eefd7f1923 100644 --- a/slideshow/source/inc/tools.hxx +++ b/slideshow/source/inc/tools.hxx @@ -293,7 +293,7 @@ namespace slideshow /// Gets a random ordinal [0,n) inline ::std::size_t getRandomOrdinal( const ::std::size_t n ) { - return comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), n-1); + return comphelper::rng::uniform_size_distribution(0, n-1); } /// To work around ternary operator in initializer lists diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index e7a7156dc06e..fe8dd092a5d3 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -965,7 +965,7 @@ getRandomPosition(SwDoc *pDoc, int /* nOffset */) { const SwPosition aPos(pDoc->GetNodes().GetEndOfContent()); size_t nNodes = aPos.nNode.GetNode().GetIndex() - aPos.nNode.GetNode().StartOfSectionIndex(); - size_t n = comphelper::rng::uniform_int_distribution(static_cast<size_t>(0), nNodes); + size_t n = comphelper::rng::uniform_size_distribution(0, nNodes); SwPaM pam(aPos); for (sal_uLong i = 0; i < n; ++i) { |