-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircularList.cpp
More file actions
61 lines (50 loc) · 1.28 KB
/
CircularList.cpp
File metadata and controls
61 lines (50 loc) · 1.28 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
/*
* File: CircularList.cpp
* Author: dabri
*
* Created on 16 May 2017, 04:28
*/
#include "CircularList.h"
#include "CircularList.h"
#include<iostream>
#include <malloc.h>
#include <stdlib.h>
#include <sstream>
using namespace std;
CircularList::CircularList() {
}
CircularList::CircularList(const CircularList& orig) {
}
CircularList::~CircularList() {
}
void CircularList::insertintoList(char value) {
LISTNODEPTR newPtr, tempPtr, previousPtr;
newPtr = (LISTNODEPTR) malloc(sizeof (LISTNODE));
newPtr->data = value;
//newPtr->nextPtr = NULL;
//guardar el head
tempPtr = startNodeList;
if (startNodeList == NULL) {
startNodeList = newPtr;
startNodeList->nextPtr = startNodeList;
tempPtr=startNodeList;
} else {
tempPtr->nextPtr = newPtr;
newPtr->nextPtr = startNodeList;
tempPtr = newPtr;
}
}
void CircularList::printList() {
//current node
LISTNODEPTR currentNode = startNodeList;
if (currentNode != NULL) {
do{
cout << currentNode-> data << endl;
currentNode = currentNode->nextPtr;
} while (currentNode != startNodeList);
// std::cout<<("NULL\n\n");
}//end if
else {
cout << "The list is empty.\n\n" << endl;
}
}