Eliminate dependency on Boost.Random
Also replace use of std::random_shuffle (removed in C++17)
with std::shuffle.
Change-Id: I200a8a404e67447c547c9abfa1a5a55a18de9ef3
diff --git a/tests/other/skiplist-list.hpp b/tests/other/skiplist-list.hpp
index 72d1dda..ca71c7f 100644
--- a/tests/other/skiplist-list.hpp
+++ b/tests/other/skiplist-list.hpp
@@ -1,26 +1,29 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
-* Copyright (c) 2014, Regents of the University of California.
-*
-* This file is part of NDN repo-ng (Next generation of NDN repository).
-* See AUTHORS.md for complete list of repo-ng authors and contributors.
-*
-* repo-ng is free software: you can redistribute it and/or modify it under the terms
-* of the GNU General Public License as published by the Free Software Foundation,
-* either version 3 of the License, or (at your option) any later version.
-*
-* repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-* PURPOSE. See the GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License along with
-* repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
-*/
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California.
+ *
+ * This file is part of NDN repo-ng (Next generation of NDN repository).
+ * See AUTHORS.md for complete list of repo-ng authors and contributors.
+ *
+ * repo-ng is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef REPO_TESTS_OTHER_SKIPLIST_LIST_HPP
#define REPO_TESTS_OTHER_SKIPLIST_LIST_HPP
+
#include "common.hpp"
+#include <random>
+
namespace update1 {
class SkipList32Levels25Probabilty
@@ -136,7 +139,7 @@
}
};
-/*
+/**
* @brief SkipList
*
* Examples of internal structure:
@@ -224,7 +227,7 @@
protected:
- /*
+ /**
* @brief initialize the node
*/
NodePointer
@@ -234,9 +237,9 @@
return p;
}
- /*
+ /**
* @brief initialize the node with given value
- * @para to be set to the value of node
+ * @param x to be set to the value of node
*/
NodePointer
createNode(const T& x)
@@ -246,9 +249,9 @@
return p;
}
- /*
- * @brief destructror of the node
- * @para given pointer of node to be destructed
+ /**
+ * @brief destructor of the node
+ * @param p pointer to the node to be destructed
*/
void
destroyNode(NodePointer p)
@@ -256,7 +259,7 @@
delete(p);
}
- /*
+ /**
* @brief initialize the head
*/
void
@@ -268,7 +271,7 @@
m_size = 0;
}
- /*
+ /**
* @brief destroy all the nodes of skiplist except the head
*/
void
@@ -284,14 +287,14 @@
m_head->prevs.front() = m_head;
}
- /*
+ /**
* @brief pick a random height for inserted skiplist entry
*/
size_t
pickRandomLevel() const
{
- static boost::random::mt19937 gen;
- static boost::random::geometric_distribution<size_t> dist(Traits::getProbability());
+ static std::mt19937 gen(std::random_device{}());
+ static std::geometric_distribution<size_t> dist(Traits::getProbability());
return std::min(dist(gen), Traits::getMaxLevels());
}
@@ -473,6 +476,6 @@
}
}
-} //end namespace update1
+} // namespace update1
-#endif // REPO_TESTS_UNIT_SKIPLIST_LIST_HPP
+#endif // REPO_TESTS_OTHER_SKIPLIST_LIST_HPP
diff --git a/tests/other/skiplist-prev.hpp b/tests/other/skiplist-prev.hpp
index 1bb416d..c19ca29 100644
--- a/tests/other/skiplist-prev.hpp
+++ b/tests/other/skiplist-prev.hpp
@@ -1,27 +1,29 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
-* Copyright (c) 2014, Regents of the University of California.
-*
-* This file is part of NDN repo-ng (Next generation of NDN repository).
-* See AUTHORS.md for complete list of repo-ng authors and contributors.
-*
-* repo-ng is free software: you can redistribute it and/or modify it under the terms
-* of the GNU General Public License as published by the Free Software Foundation,
-* either version 3 of the License, or (at your option) any later version.
-*
-* repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-* PURPOSE. See the GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License along with
-* repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
-*/
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California.
+ *
+ * This file is part of NDN repo-ng (Next generation of NDN repository).
+ * See AUTHORS.md for complete list of repo-ng authors and contributors.
+ *
+ * repo-ng is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef REPO_TESTS_OTHER_SKIPLIST_PREV_HPP
#define REPO_TESTS_OTHER_SKIPLIST_PREV_HPP
#include "common.hpp"
+#include <random>
+
namespace prev {
class SkipList32Levels25Probabilty
@@ -312,8 +314,8 @@
size_t
pickRandomLevel() const
{
- static boost::random::mt19937 gen;
- static boost::random::geometric_distribution<size_t> dist(Traits::getProbability());
+ static std::mt19937 gen(std::random_device{}());
+ static std::geometric_distribution<size_t> dist(Traits::getProbability());
return std::min(dist(gen), Traits::getMaxLevels());
}
diff --git a/tests/other/skiplist-vector.hpp b/tests/other/skiplist-vector.hpp
index 6079dd3..8ef1ed9 100644
--- a/tests/other/skiplist-vector.hpp
+++ b/tests/other/skiplist-vector.hpp
@@ -1,26 +1,29 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
-* Copyright (c) 2014, Regents of the University of California.
-*
-* This file is part of NDN repo-ng (Next generation of NDN repository).
-* See AUTHORS.md for complete list of repo-ng authors and contributors.
-*
-* repo-ng is free software: you can redistribute it and/or modify it under the terms
-* of the GNU General Public License as published by the Free Software Foundation,
-* either version 3 of the License, or (at your option) any later version.
-*
-* repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-* PURPOSE. See the GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License along with
-* repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
-*/
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California.
+ *
+ * This file is part of NDN repo-ng (Next generation of NDN repository).
+ * See AUTHORS.md for complete list of repo-ng authors and contributors.
+ *
+ * repo-ng is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef REPO_TESTS_OTHER_SKIPLIST_VECTOR_HPP
#define REPO_TESTS_OTHER_SKIPLIST_VECTOR_HPP
+
#include "common.hpp"
+#include <random>
+
namespace update2 {
class SkipList32Levels25Probabilty
@@ -290,8 +293,8 @@
size_t
pickRandomLevel() const
{
- static boost::random::mt19937 gen;
- static boost::random::geometric_distribution<size_t> dist(Traits::getProbability());
+ static std::mt19937 gen(std::random_device{}());
+ static std::geometric_distribution<size_t> dist(Traits::getProbability());
return std::min(dist(gen), Traits::getMaxLevels());
}
@@ -412,6 +415,6 @@
}
-} //end namespace update2
+} // namespace update2
#endif // REPO_TESTS_OTHER_SKIPLIST_VECTOR_HPP