-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebHistory.hpp
60 lines (44 loc) · 1.74 KB
/
WebHistory.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef WEBHISTORY_HPP
#define WEBHISTORY_HPP
#include <iostream>
#include <cstdlib>
#include "LinkedList.hpp"
#include "Tab.hpp"
// DO NOT CHANGE THIS FILE.
class WebHistory
{
public:
// GIVEN: Default Constructor
WebHistory();
// GIVEN: Construtor that takes series of urls and timestamps.
// You should implement insertInOrder function to run this function.
WebHistory(std::string history);
// TODO: Consturctor with a single tab. The tab information is given as a url and a timestamp.
WebHistory(std::string url, int timestamp);
// TODO: Destructor.
~WebHistory();
// GIVEN: Prints the history in a specific format.
void printHistory();
// TODO: Insert the given tab to list in decreasing order.
void insertInOrder(Node<Tab> *newPage);
// TODO: Insert new tab with given url and timestamp
void goToPage(std::string url, int timestamp);
// TODO: Clear all tabs from the history
void clearHistory();
// TODO: Clear pages whose timestamp is less than or equal to the given timestamp
void clearHistory(int timestamp);
// TODO: Sync two histories. Do not forget to check the timestamps while merging.
// Resulting list should still be in deacrasing order of timestamps.
WebHistory operator+(const WebHistory &rhs) const;
//BONUS PARTS
// Bonus: Return how many times the given pageName is visited.
// Hint: Use a function given in Tab class to strip the url.
int timesVisited(std::string pageName);
// Bonus: Return the most visited page. Do not use the full links.
// (i.e. if link contains www.youtube.com/etcetc it should be counted as youtube.
// Use a function given in Tab class to strip the url.)
std::string mostVisited();
private:
LinkedList<Tab> history;
};
#endif //WEBHISTORY_HPP