-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedList.c
62 lines (49 loc) · 1.21 KB
/
linkedList.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "linkedList.h"
#include "simulador.h"
#include <stdlib.h>
#include <stdio.h>
Link initList(int totalMemoria) {
Link head = Malloc(sizeof(*head));
Link tail = Malloc(sizeof(*tail));
head->info = 'P';
head->base = -1;
head->tamanho = -1;
head->ant = NULL;
head->prox = tail;
tail->info = 'P';
tail->base = -1;
tail->tamanho = -1;
tail->ant = head;
tail->prox = NULL;
insertItemList(head, 'L', 0, totalMemoria);
if(numGerEspLiv == 3){
// inicializaTabelaQuick();
// inserePonteiroTabelaQuick(totalMemoria, head->prox);
}
return head;
}
void insertItemList(Link anterior, char info, int base, int tamanho) {
Link novo = Malloc(sizeof(*novo));
novo->info = info;
novo->base = base;
novo->tamanho = tamanho;
novo->prox = anterior->prox;
anterior->prox->ant = novo;
anterior->prox = novo;
novo->ant = anterior;
}
void removeItemList(Link removido) {
Link aux = removido->ant;
aux->prox = removido->prox;
removido->prox->ant = aux;
free(removido);
removido = NULL;
}
void printList(Link head) {
Link aux;
printf("Lista: [HEAD] -> ");
for(aux = head->prox; aux->prox != NULL; aux = aux->prox) {
printf("[%c | %d | %d] -> ", aux->info, aux->base, aux->tamanho);
}
printf("[TAIL]\n\n");
}