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

Spiffing up the linked list queue

parent fa96d939
...@@ -31,7 +31,8 @@ public class LinkedListQueue implements Iterable{ ...@@ -31,7 +31,8 @@ public class LinkedListQueue implements Iterable{
if(data.isEmpty()) { if(data.isEmpty()) {
throw new RuntimeException("QueueUnderflow!"); throw new RuntimeException("QueueUnderflow!");
} }
else { Object out = head; else {
Object out = head;
data.removeFirst(); data.removeFirst();
if(!data.isEmpty()) head = data.getFirst(); if(!data.isEmpty()) head = data.getFirst();
else head = null; else head = null;
......
...@@ -143,11 +143,12 @@ public class AppTest ...@@ -143,11 +143,12 @@ public class AppTest
public void test_LL_QueueElement(){ public void test_LL_QueueElement(){
Integer test = randRange(1,10); Integer test = randRange(1,10);
LinkedListQueue q = new LinkedListQueue(); LinkedListQueue q = new LinkedListQueue();
q.add("b");
for(int k = 1; k<=10; k++){ 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