1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "lastseen.h"
- LastSeen::LastSeen(int max) {
- this->max = max;
- tracker.reserve(max);
- while ((int)tracker.size() < max)
- tracker.insert(tracker.begin(), -1);
- }
- /*
- int LastSeen::bestsize(int max_items) {
- int best = max_items / 2;
- return best;
- }
- */
- int LastSeen::getmax(void) {
- return this->max;
- }
- LastSeen::~LastSeen() { };
- bool LastSeen::seen_before(int this_one) {
- for (auto it = this->tracker.begin(); it != this->tracker.end(); ++it ) {
- if (*it == this_one)
- return true;
- }
- // Ok, it hasn't been seen before.
- this->tracker.erase(this->tracker.begin());
- this->tracker.push_back(this_one);
- return false;
- }
- int LastSeen::best_guess(int max) {
- return max / 2;
- }
|