-
Notifications
You must be signed in to change notification settings - Fork 0
/
fila.h
47 lines (38 loc) · 1.23 KB
/
fila.h
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
#ifndef FILA_AVIAO_H
#define FILA_AVIAO_H
#include "aviao.h"
/**
* Esta estrutura auxiliar deve facilitar a implementação da fila ordenada.
* Preencha a fila com elemento_t que contém os aviões apontado para o
* anterior e o próximo. Use estes ponteiros para ordenar a fila a cada
* insercão
**/
typedef struct elemento_t {
struct elemento_t * anterior;
struct elemento_t * proximo;
aviao_t * dado;
} elemento_t;
// Alocacao dinamica do elemento
elemento_t * aloca_elemento (aviao_t * dado);
void desaloca_elemento (elemento_t * elemento);
/**
* Esta estrutura de dados deve conter uma fila de aviões odernada por
* prioridade.
**/
typedef struct {
elemento_t * primeiro;
elemento_t * ultimo;
size_t n_elementos;
size_t pouco_combustivel;
} fila_ordenada_t;
// Alocacão dinâmica da fila ordenada de aviões
fila_ordenada_t * criar_fila (size_t pouco_combustivel);
// Desaloca a fila.
// Não se esqueca de desalocar todos os elementos antes de finalizar.
void desaloca_fila (fila_ordenada_t * fila);
// Insere dados de forma ordenada na fila
// Não se esqueca de criar o elemento_t
void inserir (fila_ordenada_t * fila, aviao_t * dado);
// Remove o último da fila.
aviao_t * remover (fila_ordenada_t * fila);
#endif