scala
class Enumeration

[source: `scala/Enumeration.scala`]

`abstract` `class` Enumeration(initial : Int, names : String*)
  `extends` AnyRef

  Defines a finite set of values specific to the enumeration. Typically these values enumerate all possible forms something can take and provide a lightweight alternative to case classes.

  Each call to a `Value` method adds a new unique value to the enumeration. To be accessible, these values are usually defined as `val` members of the evaluation.

  All values in an enumeration share a common, unique type defined as the `Value` type member of the enumeration (`Value` selected on the stable identifier path of the enumeration instance).

  Example use

        object Main extends Application {

          object WeekDays extends Enumeration {
            val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
          }

          def isWorkingDay(d: WeekDays.Value) =
            ! (d == WeekDays.Sat || d == WeekDays.Sun)

          WeekDays filter (isWorkingDay) foreach { d => Console.println(d) }
        }

Parameters
  `initial -` The initial value from which to count the integers that identifies values at run-time.
  `names -` The sequence of names to give to this enumeration's values.
Author
  Matthias Zenger
Version
  1.0, 10/02/04

Additional Constructor Summary
`def` | this : Enumeration
`def` | this (names : String*) : Enumeration

Value Summary
`protected var` | nextId : Int The integer to use to identify the next created value.
`protected var` | nextName : Iterator[String] The string to use to name the next created value.

Method Summary
`def` | Set32 : Set32 create an empty 32 bit enumeration set
`def` | Set32 (underlying : Int) : Set32 create a bit enumeration set according ot underlying
`def` | Set64 (underlying : Long) : Set64 create a bit enumeration set according ot underlying
`def` | Set64 : Set64 create an empty 64 bit enumeration set
`protected final def` | Value (i : Int) : Value Creates a fresh value, part of this enumeration, identified by the integer `i`.
`protected final def` | Value (i : Int, name : String) : Value Creates a fresh value, part of this enumeration, called `name` and identified by the integer `i`.
`protected final def` | Value : Value Creates a fresh value, part of this enumeration.
`protected final def` | Value (name : String) : Value Creates a fresh value, part of this enumeration, called `name`.
`final def` | apply (x : Int) : Value The value in this enumeration identified by integer `x`.
`final def` | elements : Iterator[Value] A new iterator over all values of this enumeration.
`def` | exists (p : (Value) => Boolean) : Boolean Apply a predicate p to all values of this enumeration and return true, iff there is at least one value for which p yields true.
`def` | filter (p : (Value) => Boolean) : Iterator[Value] Returns all values of this enumeration that satisfy the predicate p. The order of values is preserved.
`def` | flatMap [b](f : (Value) => Iterator[b]) : Iterator[b] Applies the given function f to each value of this enumeration, then concatenates the results.
`def` | forall (p : (Value) => Boolean) : Boolean Apply a predicate p to all values of this enumeration and return true, iff the predicate yields true for all values.
`def` | foreach (f : (Value) => Unit) : Unit Apply a function f to all values of this enumeration.
`def` | map [b](f : (Value) => b) : Iterator[b] Returns an iterator resulting from applying the given function f to each value of this enumeration.
`def` | maskToBit (n : Long) : Int used to reverse engineer bit locations from pre-defined bit masks
`final def` | maxId : Int The highest integer amongst those used to identify values in this enumeration.
`def` | name : String The name of this enumeration.
`override def` | toString : String

Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Class Summary
`class` | Set32 (`val` underlying : Int)`extends` SetXX An enumeration bit set that can handle enumeration values with ids up to 31 in an `Int`.
`class` | Set64 (`val` underlying : Long)`extends` SetXX An enumeration bit set that can handle enumeration values with ids up to 63 in a `Long`.
`abstract class` | SetXX `extends` Set[Value] A set that efficiently stores enumeration values as bits.
`protected class` | Val (i : Int, name : String)`extends` Value A class implementing the `Value` type. This class can be overriden to change the enumeration's naming and integer identification behaviour.
`abstract class` | Value `extends` Ordered[Value] The type of the enumerated values.

Additional Constructor Details

`` `def` this : Enumeration

`` `def` this(names : String*) : Enumeration

Value Details

`protected` `var` nextId : Int

  The integer to use to identify the next created value.

`protected` `var` nextName : Iterator[String]

  The string to use to name the next created value.

Method Details

`` `def` name : String

  The name of this enumeration.

`final` `def` maxId : Int

  The highest integer amongst those used to identify values in this enumeration.

`final` `def` apply(x : Int) : Value

  The value in this enumeration identified by integer `x`.

`final` `def` elements : Iterator[Value]

  A new iterator over all values of this enumeration.

`` `def` foreach(f : (Value) => Unit) : Unit

  Apply a function f to all values of this enumeration.

`` `def` forall(p : (Value) => Boolean) : Boolean

  Apply a predicate p to all values of this enumeration and return true, iff the predicate yields true for all values.

`` `def` exists(p : (Value) => Boolean) : Boolean

  Apply a predicate p to all values of this enumeration and return true, iff there is at least one value for which p yields true.

`` `def` map[b](f : (Value) => b) : Iterator[b]

  Returns an iterator resulting from applying the given function f to each value of this enumeration.

`` `def` flatMap[b](f : (Value) => Iterator[b]) : Iterator[b]

  Applies the given function f to each value of this enumeration, then concatenates the results.

`` `def` filter(p : (Value) => Boolean) : Iterator[Value]

  Returns all values of this enumeration that satisfy the predicate p. The order of values is preserved.

`override` `def` toString : String

`protected final` `def` Value : Value

  Creates a fresh value, part of this enumeration.

`protected final` `def` Value(i : Int) : Value

  Creates a fresh value, part of this enumeration, identified by the integer `i`.

Parameters
  `i -` An integer that identifies this value at run-time. It must be unique amongst all values of the enumeration.
Returns
  ..

`protected final` `def` Value(name : String) : Value

  Creates a fresh value, part of this enumeration, called `name`.

Parameters
  `name -` A human-readable name for that value.

`protected final` `def` Value(i : Int, name : String) : Value

  Creates a fresh value, part of this enumeration, called `name` and identified by the integer `i`.

Parameters
  `i -` An integer that identifies this value at run-time. It must be unique amongst all values of the enumeration.
  `name -` A human-readable name for that value.
Returns
  ..

`` `def` Set32 : Set32

  create an empty 32 bit enumeration set

`` `def` Set32(underlying : Int) : Set32

  create a bit enumeration set according ot underlying

`` `def` Set64 : Set64

  create an empty 64 bit enumeration set

`` `def` Set64(underlying : Long) : Set64

  create a bit enumeration set according ot underlying

`` `def` maskToBit(n : Long) : Int

  used to reverse engineer bit locations from pre-defined bit masks