mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
refs #481 Removed old randomElements.
This commit is contained in:
@@ -338,23 +338,6 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
void remove(const CCollection &other) { *this = CCollection(*this).difference(other); }
|
void remove(const CCollection &other) { *this = CCollection(*this).difference(other); }
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Return some random elements from container
|
|
||||||
* \param elements how many elements
|
|
||||||
*/
|
|
||||||
CCollection randomElements(int elements) const
|
|
||||||
{
|
|
||||||
if (this->isEmpty() || elements < 1) { return CCollection(); }
|
|
||||||
int high = this->size();
|
|
||||||
CCollection r;
|
|
||||||
for (int i = 0; i < elements; i++)
|
|
||||||
{
|
|
||||||
int randomIndex = qrand() % high;
|
|
||||||
r.push_back(*(this->begin()+ randomIndex));
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Test for equality.
|
* \brief Test for equality.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -518,23 +518,6 @@ namespace BlackMisc
|
|||||||
return sorted(BlackMisc::Predicates::MemberLess(key1, keys...));
|
return sorted(BlackMisc::Predicates::MemberLess(key1, keys...));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Return some random elements from container
|
|
||||||
* \param elements how many elements
|
|
||||||
*/
|
|
||||||
CSequence randomElements(int elements) const
|
|
||||||
{
|
|
||||||
if (this->isEmpty() || elements < 1) { return CSequence(); }
|
|
||||||
int high = this->size();
|
|
||||||
CSequence r;
|
|
||||||
for (int i = 0; i < elements; i++)
|
|
||||||
{
|
|
||||||
int randomIndex = qrand() % high;
|
|
||||||
r.push_back(this->operator [](randomIndex));
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Equals operator.
|
//! Equals operator.
|
||||||
friend bool operator ==(const CSequence &a, const CSequence &b)
|
friend bool operator ==(const CSequence &a, const CSequence &b)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user