-
Notifications
You must be signed in to change notification settings - Fork 2
/
Cola.h
105 lines (83 loc) · 1.78 KB
/
Cola.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*!Begin Snippet:filebegin*/
#ifndef _Cola_H_
#define _Cola_H_
#include "Lista.h"
using namespace std;
//Cola de Listas
/*!Begin Snippet:fullNodo*/
/*!Begin Snippet:private*/
template <typename T>
class Cola : public Lista<T> {
private:
int duenio; // ip_equipo asociado
int tamanio_max; //
public:
Cola();
Cola(int);
Cola(int, int);
~Cola();
void encolar(T);
void desencolar();
int obtener_duenio();
void reencolar();
int obtener_tamanio_max();
void fijar_tamanio_max(int);
bool cola_llena();
void imprimir();
};
template <typename T>
Cola<T>::Cola(){
//Lista();
this->duenio=-1;
this->tamanio_max=-1;
}
template <typename T>
Cola<T>::Cola(int duenio){
//Lista();
this->duenio=duenio;
this->tamanio_max=-1;
}
template <typename T>
Cola<T>::Cola(int duenio, int tamanio_max){
//Lista();
this->duenio=duenio;
this->tamanio_max=tamanio_max;
}
template <typename T>
Cola<T>::~Cola(){}
template <typename T>
void Cola<T>::encolar(T elemento){
assert(!this->cola_llena() && "Se intenta agregar elementos a una cola llena"); // si la cola esta llena, mando el mensaje
this->insertar_al_final(elemento);
}
template <typename T>
void Cola<T>::desencolar(){
Lista<T>::quitar_primer_nodo();
}
template <typename T>
void Cola<T>::reencolar(){
T primer_elem = Lista<T>::primer_elemento();
Lista<T>::quitar_primer_nodo();
encolar(primer_elem);
}
template <typename T>
int Cola<T>::obtener_duenio(){
return duenio;
}
template <typename T>
int Cola<T>::obtener_tamanio_max(){
return tamanio_max;
}
template <typename T>
bool Cola<T>::cola_llena(){
return this->tamanio() == tamanio_max;
}
template <typename T>
void Cola<T>::fijar_tamanio_max(int tam_max){
this->tamanio_max = tam_max;
}
template <typename T>
void Cola<T>::imprimir(void){
Lista<T>::imprimir();
}
#endif