# Conflicts:
#	Data Structures/HashMap/HashMap.java
#	Huffman.java
#	Misc/FloydTriangle.java
#	Misc/Huffman.java
#	Misc/InsertDeleteInArray.java
#	Misc/RootPrecision.java
#	Misc/ft.java
#	Misc/root_precision.java
#	Others/FloydTriangle.java
#	Others/Huffman.java
#	Others/insert_delete_in_array.java
#	Others/root_precision.java
#	insert_delete_in_array.java
This commit is contained in:
DESKTOP-0VAEMFL\joaom
2017-10-28 12:59:58 +01:00
58 changed files with 2697 additions and 114 deletions

View File

@ -42,7 +42,7 @@ class Stack{
top++;
stackArray[top] = value;
}else{
System.out.println("The stack is full, can't insert value");
resize(maxSize*2);
}
}
@ -54,7 +54,12 @@ class Stack{
public int pop(){
if(!isEmpty()){ //Checks for an empty stack
return stackArray[top--];
}else{
}
if(top < maxSize/4){
resize(maxSize/2);
}
else{
System.out.println("The stack is already empty");
return -1;
}
@ -74,6 +79,16 @@ class Stack{
}
}
private void resize(int newSize){
private int[] transferArray = new int[newSize];
for(int i = 0; i < stackArray.length(); i++){
transferArray[i] = stackArray[i];
stackArray = transferArray;
}
maxSize = newSize;
}
/**
* Returns true if the stack is empty
*