Permalink
Browse files

Add NoSuchElementException for next() in iterator implementation

  • Loading branch information...
Jakk.Wong@gmail.com Jakk.Wong@gmail.com
Jakk.Wong@gmail.com authored and Jakk.Wong@gmail.com committed Sep 6, 2012
1 parent d770152 commit de66232a2249025b9676d97b4453a609b3208375
Showing with 2 additions and 0 deletions.
  1. +1 −0 HW2/Deque.java
  2. +1 −0 HW2/RandomizedQueue.java
View
@@ -91,6 +91,7 @@ public boolean hasNext() {
}
public Item next() {
+ if (!hasNext()) throw new java.util.NoSuchElementException("End of deque reached.");
Item item = current.item;
current = current.next;
return item;
View
@@ -80,6 +80,7 @@ public boolean hasNext() {
}
public Item next() {
+ if (!hasNext()) throw new java.util.NoSuchElementException("End of randomized queue reached.");
return copy[--i];
}

0 comments on commit de66232

Please sign in to comment.