-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCola.java
More file actions
48 lines (41 loc) · 1015 Bytes
/
Copy pathCola.java
File metadata and controls
48 lines (41 loc) · 1015 Bytes
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
/**
*
* @author Issei
*/
public class Cola {
NodoCola inicio = null;
NodoCola fin = null;
void queue(char dato) {
NodoCola nuevo = new NodoCola();
nuevo.dato = dato;
nuevo.siguiente = null;
nuevo.anterior = null;
if (inicio != null) {
inicio.anterior = nuevo;
nuevo.siguiente = inicio;
} else {
inicio = nuevo;
fin = nuevo;
}
}
char dequeue() {
char letra;
if (fin != null) {
NodoCola aux = fin;
if (inicio == fin) {
inicio = null;
// System.out.println("un elemento");
fin = null;
} else {
fin = fin.anterior;
fin.siguiente = null;
}
aux.siguiente = null;
aux.anterior = null;
letra = aux.dato;
} else {
letra = 0;
}
return letra;
}
}