-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLL.cpp
More file actions
103 lines (92 loc) · 1.89 KB
/
Copy pathLL.cpp
File metadata and controls
103 lines (92 loc) · 1.89 KB
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
99
100
101
102
103
//
// LL.cpp
// PG4 V4
//
// Created by Lawrence Johnson on 11/1/14.
// Copyright (c) 2014 Lawrence Johnson. All rights reserved.
//
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm> // V2 added
#include "LL.h"
#include "LLN.h"
using namespace std;
/*
Create an empty Linked List
*/
LL::LL () {
head = NULL;
}
/*
Delete Linked List
*/
LL::~LL () {
delete head;
}
/*
Add string to the front of the Linked List
*/
void LL::addfront (string I) {
head = new LLN (I,head);
}
/*
Add string to the back of the Linked List
*/
void LL::addback (string I) {
if (head==NULL) head = new LLN (I,NULL);
else head->addback (I);
}
/*
Print Linked List
*/
void LL::print () {
if (head != NULL) head->printall ();
cout << endl;
}
/*
Add string to the order of lowest to highest to the Linked List
*/
void LL::addinorder (string I) {
if (!head) head = new LLN (I,NULL);
else head = head->addinorder_0 (I);
}
/*
Delete first appearance of a string
*/
void LL::delfirst (string I) {
if (!head) return;
head = head->delfirst (I);
}
/*
Delete first appearance of a string
*/
void LL::delfirst_0 (string I) {
if (!head) return;
head->delfirst_0 (I,NULL,this);
}
/*
Delete first appearance of a string
*/
void LL::sethead (LLN *h) {head = h;}
/*
Delete all appearences of a word
*/
void LL::DelInitial (string c) {
if (head) head = head->DelInitial (c);
}
/*
Check if the book title already appears in the list
*/
bool LL::check(string s){
transform(s.begin(), s.end(), s.begin(), ::tolower);
bool match = false;
if (!head) return match;
if (head && head->geti() != s) match = head->check(s);
string temp = head->geti();
transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
if (temp == s) {
return true;
}
return match;
}