#include "lastseen.h"

LastSeen::LastSeen(int max_nondups) {
  this->max = max_nondups;
  this->tracker = new int[max_nondups];
  for (int i = 0; i < max_nondups; i++) {
    this->tracker[i] = -1;
  }
}

LastSeen::~LastSeen() { delete this->tracker; }

bool LastSeen::seen_before(int this_one) {
  int i;
  for (i = 0; i < this->max; i++) {
    if (this->tracker[i] == this_one)
      return true;
  }
  // Ok, it hasn't been seen before.
  for (i = 0; i < this->max - 1; i++) {
    this->tracker[i] = this->tracker[i + 1];
  };
  this->tracker[i] = this_one;
  return false;
}