eliminato classi superflue del progetto e risolto qualche bug. c'è ancora del lavoro da fare sulla queue e deque

This commit is contained in:
2014-03-23 22:00:57 +01:00
parent 6f3e597f65
commit e3059ed799
10 changed files with 94 additions and 322 deletions

View File

@@ -1,7 +1,6 @@
package stack;
import exceptions.EmptyStackException;
import exceptions.FullStackException;
import stack.utility.Node;
/**
@@ -15,7 +14,7 @@ import stack.utility.Node;
public class NodeStack<E> implements Stack<E> {
@Override
public void push(E element) throws FullStackException {
public void push(E element) {
Node<E> temp = new Node<E>(element,stack);
stack = temp;
++number_of_elements;
@@ -60,6 +59,24 @@ public class NodeStack<E> implements Stack<E> {
return number_of_elements;
}
@Override
public String toString() {
String to_return = "";
to_return = to_return + "[";
for ( Node<E> temp = stack; temp != null ; temp = temp.getNext()){
if ( temp.getNext() == null){
to_return+=(temp.getElement().toString());
}else{
to_return+=( temp.getElement().toString() + ",");
}
}
to_return = to_return + "]";
return to_return;
}
private Node<E> stack = null;
private int number_of_elements = 0;