Skip to content

Instantly share code, notes, and snippets.

@tonussi
Created April 5, 2013 02:36
Show Gist options
  • Save tonussi/5316165 to your computer and use it in GitHub Desktop.
Save tonussi/5316165 to your computer and use it in GitHub Desktop.
Fila acorrentada.
public class Elemento<E> {
public Elemento(Elemento<E> elemento, Object object) {
}
public Elemento<E> getProx() {
return null;
}
public void setProx(Elemento<?> topo) {
}
public E getValor() {
return null;
}
}
public class FilaCadeia {
Elemento<?> topo;
FilaCadeia() {
topo = null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
void push(Elemento<?> elemento) {
Elemento<?> novo = new Elemento(elemento, null);
novo.setProx(topo);
topo = novo;
}
Elemento<?> pop() {
Elemento<?> aux = (Elemento<?>) topo.getValor();
topo = topo.getProx();
return aux;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment