-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrowserHistory.cpp
98 lines (75 loc) · 1.57 KB
/
BrowserHistory.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Created by Sparsh on 2/5/2021.
// Dequeue Class
#include "BrowserHistory.h"
#include "WebsiteList.h"
#include "WebsiteData.h"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int listSize = 0;
bool BrowserHistory::pop_front() {
if (listSize == 0) {
return false;
} else {
deleteFirstElement();
listSize--;
cout<<listSize<<endl;
return true;
}
}
bool BrowserHistory::push_back(string urlName, string url) {
setNext(urlName, url);
listSize++;
return true;
}
bool BrowserHistory::pop_back() {
if (listSize != 0) {
deleteLastElement();
listSize--;
return true;
} else {
return false;
}
}
bool BrowserHistory::push_front(string urlName, string url) {
addToTop(urlName, url);
listSize++;
return true;
}
int BrowserHistory::size() {
return listSize;
}
WebsiteData * BrowserHistory::front() {
if (listSize > 0) {
return getHead();
} else {
return NULL;
}
}
WebsiteData * BrowserHistory::back() {
if (listSize > 0) {
return getTail();
} else {
return NULL;
}
}
string BrowserHistory::empty() {
if (listSize == 0) {
return "empty 1";
} else {
return "empty 0";
}
}
void BrowserHistory::clear() {
deleteAll();
listSize = 0;
}
WebsiteData * BrowserHistory::find(string urlName) {
transform(urlName.begin(), urlName.end(), urlName.begin(), ::tolower);
return findData(urlName);
}
void BrowserHistory::print() {
printBackwards();
}