-
Notifications
You must be signed in to change notification settings - Fork 0
/
myList.c
46 lines (41 loc) · 910 Bytes
/
myList.c
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
#include "myList.h"
#include <stdlib.h>
TList* createList(){
TList* this=(TList*)malloc(sizeof(TNode));
this->actual=NULL;
this->first=NULL;
return this;
}
void destroyList(TList* this){
TNode* nodeToDestroy;
this->actual=this->first;
nodeToDestroy=getNext(this->actual);
while(nodeToDestroy != NULL){
this->actual=getNext(nodeToDestroy);
destroyNode(nodeToDestroy);
nodeToDestroy=this->actual;
}
destroyNode(this->first);
free(this);
}
TNode* getActual(TList* this){
return (this->actual);
}
void addNode(TList* this, TNode* node){
if (this->first == NULL){
this->first=node;
this->actual=node;
}else{
(this->actual)->next = node;
this->actual = node;
}
}
void printMovements(TList* this){
//El primero
this->actual=this->first;
printf("%s",this->actual->info);
//Los del medio
while ((this->actual=getNext(this->actual))!=NULL){
printf("%s",this->actual->info);
}
}