We should consider deduplication as well.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+#include <iterator>
#include <map>
#include <set>
#include <boost/scoped_ptr.hpp>
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont)) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
string num_str(unsigned i) {
*/
#include <iostream>
+#include <iterator>
#include <sstream>
#include <boost/scoped_ptr.hpp>
#include "os/filestore/FileStore.h"
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont)) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
int main(int argc, char **argv) {
#include "include/rados/librados.hpp"
#include <iostream>
+#include <iterator>
#include <sstream>
#include <map>
#include <set>
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont)) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
enum TestOpType {
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+#include <iterator>
#include <map>
#include <set>
#include <boost/scoped_ptr.hpp>
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont)) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
string random_string(size_t size)
#include <time.h>
#include <string.h>
#include <iostream>
+#include <iterator>
#include <sstream>
#include "os/filestore/FileStore.h"
#include "include/Context.h"
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont) == 0) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
class OnApplied : public Context {