Skip to content
history.cc 587 B
Newer Older
Seblu's avatar
Seblu committed
#include "slc.hh"
#include "history.hh"

History::History(size_t size) : size_(size) {}

History::~History() {
  // save into file;
}

void History::add(const string &line) {
  if (line.empty())
    return;
Seblu's avatar
Seblu committed
  if (table_.size() + 1 > size_)
    table_.erase(table_.begin());
  table_.push_back(line);
  ++size_;
}

const string &History::get(size_t off) const {
  assert(table_.size() > 0);
  assert(off < table_.size());
  return table_[table_.size() - 1 - off];
}

const string &History::get() const {
  return table_.back();
}

size_t History::size() const {
  return table_.size();
}