Kaydet (Commit) fb6d3b88 authored tarafından Caolán McNamara's avatar Caolán McNamara

disambiguate uniform_int_distribution

Change-Id: Ifa0c1b1983d1cc7f22d55b15dee88b7f709dbcf8
üst 75a23240
......@@ -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)
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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 );
......
......@@ -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
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment