Commit 3d27f6c3 authored by michael lundquist's avatar michael lundquist
Browse files

Spiffing up the linked list queue

parent fa96d939
......@@ -31,11 +31,12 @@ public class LinkedListQueue implements Iterable{
if(data.isEmpty()) {
throw new RuntimeException("QueueUnderflow!");
}
else { Object out = head;
data.removeFirst();
if(!data.isEmpty()) head = data.getFirst();
else head = null;
return out;
else {
Object out = head;
data.removeFirst();
if(!data.isEmpty()) head = data.getFirst();
else head = null;
return out;
}
}
......
......@@ -143,11 +143,12 @@ public class AppTest
public void test_LL_QueueElement(){
Integer test = randRange(1,10);
LinkedListQueue q = new LinkedListQueue();
q.add("b");
for(int k = 1; k<=10; k++){
q.push("a");
q.add("a");
}
q.push("b");
assertTrue(true);
assertTrue(q.remove().equals("b"));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment