summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/EmptySet.scala
blob: 64f5f756323b00046fb630a9eab701880acf065e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2007, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$



package scala.collection.immutable

/** This class implements empty immutable sets
 *  @author  Martin Oderskty
 *  @version 1.0, 019/01/2007
 */
@serializable
class EmptySet[A] extends Set[A] {

  def empty[C]: Set[C] = new EmptySet[C]

  def size: Int = 0

  def contains(elem: A): Boolean = false

  def + (elem: A): Set[A] = new Set1(elem)

  def - (elem: A): Set[A] = this

  def elements: Iterator[A] = Iterator.empty
}