-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircular.cpp
41 lines (33 loc) · 967 Bytes
/
circular.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
/**
* Script com exemplo de utilização de lista encadeada circular
*
*/
#include <iostream>
#include <unistd.h>
#include "linkedlist.h"
using namespace std;
/**
* Função para criar uma lista encadeada circular
*/
StringNode * createCircularLinkedList() {
StringNode * ringOne = new StringNode("Ring one");
StringNode * ringTwo = new StringNode("Ring two");
StringNode * ringThree = new StringNode("Ring three");
ringOne->next = ringTwo;
ringTwo->next = ringThree;
ringThree->next = ringOne;
}
/**
* Função para visualizar (de forma infinita) a lista encadeada circular
*/
void viewCircularLinkedList(StringNode * circularList) {
if (circularList != NULL) {
cout << circularList->content << endl;
usleep(2*100000);
return viewCircularLinkedList(circularList->next);
}
}
int main(void) {
StringNode * circularList = createCircularLinkedList();
viewCircularLinkedList(circularList);
}