diff options
author | Burak Emir <emir@epfl.ch> | 2006-10-10 14:25:20 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-10-10 14:25:20 +0000 |
commit | de4eb301bc40ca4b7cb315843f660168451e728b (patch) | |
tree | d77ad3b9a71d4bdd8287a99f91163e96276d02fb /src/library/scala/collection/immutable/ListSet.scala | |
parent | 2995f1a6a4eb2c95399e125500ce6143f9ce7465 (diff) | |
download | scala-de4eb301bc40ca4b7cb315843f660168451e728b.tar.gz scala-de4eb301bc40ca4b7cb315843f660168451e728b.tar.bz2 scala-de4eb301bc40ca4b7cb315843f660168451e728b.zip |
exceptions
Diffstat (limited to 'src/library/scala/collection/immutable/ListSet.scala')
-rw-r--r-- | src/library/scala/collection/immutable/ListSet.scala | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index 2924e4ef96..65d5c930ed 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -30,6 +30,8 @@ object ListSet { [serializable] class ListSet[A] extends AnyRef with Set[A] { + import java.util.NoSuchElementException + /** Returns the number of elements in this set. * * @return number of set elements. @@ -58,13 +60,14 @@ class ListSet[A] extends AnyRef with Set[A] { /** Creates a new iterator over all elements contained in this set. * + * @throws java.util.NoSuchElementException * @return the new iterator */ def elements: Iterator[A] = new Iterator[A] { var that: ListSet[A] = ListSet.this; def hasNext = !that.isEmpty; def next: A = - if (!hasNext) error("next on empty iterator") + if (!hasNext) throw new NoSuchElementException("next on empty iterator") else { val res = that.elem; that = that.next; res } } @@ -78,8 +81,15 @@ class ListSet[A] extends AnyRef with Set[A] { } else false - protected def elem: A = error("Set has no elelemnts"); - protected def next: ListSet[A] = error("Next of an empty set"); + /** + * @throws java.util.NoSuchElementException + */ + protected def elem: A = throw new NoSuchElementException("Set has no elelemnts"); + + /** + * @throws java.util.NoSuchElementException + */ + protected def next: ListSet[A] = throw new NoSuchElementException("Next of an empty set"); [serializable] protected class Node(override protected val elem: A) extends ListSet[A] { |