From 01fcbeb60da0bff33d5d9f5b870d444cc418a01d Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 28 Feb 2019 20:12:45 -0500 Subject: Converted to C++ style randomization The logic in rawr::randomSentence with the cuts might be slightly different now but who even knows what's going on there. --- histogram.cpp | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 histogram.cpp (limited to 'histogram.cpp') diff --git a/histogram.cpp b/histogram.cpp deleted file mode 100644 index 77c5c3e..0000000 --- a/histogram.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "histogram.h" -#include "kgramstats.h" -#include -#include - -template -void histogram::add(const T& inst) -{ - freqtable[inst]++; -} - -template -void histogram::compile() -{ - distribution.clear(); - - int max = 0; - for (auto& it : freqtable) - { - max += it.second; - distribution.emplace(max, it.first); - } - - freqtable.clear(); -} - -template -const T& histogram::next() const -{ - int max = distribution.rbegin()->first; - int r = rand() % max; - - return distribution.upper_bound(r)->second; -} - -template -void histogram::print() const -{ - for (auto& freqpair : freqtable) - { - std::cout << freqpair.first << ": " << freqpair.second << std::endl; - } -} - -template class histogram ; -template class histogram ; -- cgit 1.4.1