std::shared_ptr<link>
last;
91 first= std::make_shared<link>();
100 void erase(
intold_elem);
102std::shared_ptr<link>
search(
intfind_elem);
112 if(
last==
nullptr) {
125 first->succ() = std::make_shared<link>(new_elem);
128 last->succ() = std::make_shared<link>(new_elem);
139 first->succ() = std::make_shared<link>(new_elem);
142std::shared_ptr<link> t = std::make_shared<link>(new_elem);
143t->succ() =
first->succ();
154std::cout <<
"List is Empty!";
157std::shared_ptr<link> t =
first;
158std::shared_ptr<link> to_be_removed =
nullptr;
159 while(t !=
last&& t->succ()->val() != old_elem) {
163std::cout <<
"Element not found\n";
166to_be_removed = t->succ();
167t->succ() = t->succ()->succ();
168to_be_removed.reset();
169 if(t->succ() ==
nullptr) {
183std::cout <<
"List is Empty!";
186std::shared_ptr<link> t =
first;
187 while(t->succ() !=
nullptr) {
188std::cout << t->succ()->val() <<
"\t";
199std::cout <<
"List is Empty!";
202std::shared_ptr<link> t =
first;
203 while(t !=
last&& t->succ()->val() != find_elem) {
207std::cout <<
"Element not found\n";
210std::cout <<
"Element was found\n";
228std::cout <<
"\n1. Insert";
229std::cout <<
"\n2. Delete";
230std::cout <<
"\n3. Search";
231std::cout <<
"\n4. Print";
232std::cout <<
"\n0. Exit";
233std::cout <<
"\n\nEnter you choice : ";
237std::cout <<
"\nQuitting the program...\n";
240std::cout <<
"\nEnter the element to be inserted : ";
247std::cout <<
"Wrong Input!\n";
251std::cout <<
"\nEnter the element to be removed : ";
257std::cout <<
"Wrong Input!\n";
261std::cout <<
"\nEnter the element to be searched : ";
265std::shared_ptr<data_structures::linked_list::link> found =
268std::cout <<
"Wrong Input!\n";
276std::cout <<
"Invalid Input\n"<< std::endl;
279}
while(choice != 0);
int pvalue
value of the current link
std::shared_ptr< link > & succ()
std::shared_ptr< link > psucc
pointer to the next value on the list
std::shared_ptr< link > search(int find_elem)
void push_front(int new_elem)
std::shared_ptr< link > first
link before the actual first element
std::shared_ptr< link > last
last link on the list
void push_back(int new_elem)
bool isDigit(const std::string &s)
Functions for singly linked list algorithm.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4