/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
*/
#include "squid.h"
+#include "splay.h"
+#include "util.h"
#include <cstdlib>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-
-#include "splay.h"
-#include "util.h"
+#include <random>
class intnode
{
int
main(int argc, char *argv[])
{
+ std::mt19937 generator;
+ xuniform_int_distribution<int> distribution;
+ auto nextRandom = std::bind (distribution, generator);
+
{
- int i;
- intnode *I;
/* test void * splay containers */
splayNode *top = NULL;
- squid_srandom(time(NULL));
- for (i = 0; i < 100; ++i) {
- I = (intnode *)xcalloc(sizeof(intnode), 1);
- I->i = squid_random();
+ for (int i = 0; i < 100; ++i) {
+ intnode *I = (intnode *)xcalloc(sizeof(intnode), 1);
+ I->i = nextRandom();
if (top)
top = top->insert(I, compareintvoid);
else
for ( int i = 0; i < 100; ++i) {
intnode *I;
I = new intnode;
- I->i = squid_random();
+ I->i = nextRandom();
safeTop = safeTop->insert(I, compareint);
}
for (int i = 0; i < 100; ++i) {
intnode I;
- I.i = squid_random();
+ I.i = nextRandom();
safeTop = safeTop->insert(I, compareintref);
}
for (int i = 0; i < 100; ++i) {
intnode I;
- I.i = squid_random();
+ I.i = nextRandom();
if (I.i > 50 && I.i < 10000000)
safeTop->insert(I, compareintref);