Skip to content

Instantly share code, notes, and snippets.

@VictorSouzas
Created December 3, 2017 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VictorSouzas/99d67efb66dac2cad4f1c42925e3e2a2 to your computer and use it in GitHub Desktop.
Save VictorSouzas/99d67efb66dac2cad4f1c42925e3e2a2 to your computer and use it in GitHub Desktop.
package pilhas;
public class Pilhaa {
private int vetor[];
private int top;
public Pilhaa(int max){
this.vetor = new int[max];
this.top = -1;
}
public boolean isEmpty(){
if(this.top == -1)
return true;
else
return false;
}
public boolean isFull(){
if(this.top == this.vetor.length -9)
return true;
else
return false;
}
public int size(){
return vetor.length;
}
public int top(){
if(isEmpty())
return this.vetor[this.top];
else
return 0;
}
public int peek(){
if(isEmpty())
return 0;
int retirado = this.vetor[this.top];
this.top--;
return retirado;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment