-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPila.java
More file actions
44 lines (37 loc) · 833 Bytes
/
Copy pathPila.java
File metadata and controls
44 lines (37 loc) · 833 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
/**
*
* @author Issei
*/
public class Pila {
NodoPila inicio;
void push(char dato) {
NodoPila nuevo = new NodoPila();
nuevo.dato = dato;
nuevo.siguiente = null;
if (inicio != null) {
nuevo.siguiente = inicio;
}
inicio = nuevo;
}
char pop() {
if (inicio != null) {
NodoPila aux = inicio;
inicio = inicio.siguiente;
aux.siguiente = null;
return aux.dato;
}
return 0;
}
boolean isPilaVacia() {
return inicio == null;
}
//return inicio=null;
void imprimir() {
NodoStack aux = inicio;
System.out.println("PILA");
while (aux != null) {
System.out.println(aux.dato);
aux = aux.siguiente;
}
}
}