You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

33 lines
752 B

#include "BrowsingHistory.h"
BrowsingHistory::BrowsingHistory() :
history(),
currentPosition(0) {}
void BrowsingHistory::addEntry(URL url) {
if (!history.empty()) {
++currentPosition;
}
if (currentPosition < history.size()) {
history.erase(history.begin() + currentPosition, history.end());
}
history.push_back(url);
}
URL const& BrowsingHistory::goForward() {
if (currentPosition < history.size()) {
++currentPosition;
}
return history[currentPosition];
}
URL const& BrowsingHistory::goBack() {
if (currentPosition > 0) {
--currentPosition;
}
return history[currentPosition];
}
std::vector<URL> const& BrowsingHistory::getHistory() const {
return history;
}