in scala/collection/mutable
class ImmutableSetAdaptor

class ImmutableSetAdaptor[A](s: Set[A])
extends Set[A]
with ScalaObject

This class can be used as an adaptor to create mutable sets from immutable set implementations. Only method empty has to be redefined if the immutable set on which this mutable set is originally based is not empty. empty is supposed to return the representation of an empty set.
Author:
Matthias Zenger
Version:
1.0, 21/07/2003

Method Summary
  def +=(elem: A): Unit
     This method adds a new element to the set.
  def -=(elem: A): Unit
     -= can be used to remove a single element from a set.
  def clear: Unit
     Removes all elements from the set.
  def contains(elem: A): Boolean
     Checks if this set contains element elem.
  def elements: Iterator[A]
     Creates a new iterator over all elements contained in this object.
protected def empty: Set[A]
override def exists(p: (A) => Boolean): Boolean
     Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
override def foreach(f: (A) => Unit): Unit
     Apply a function f to all elements of this iterable object.
override def isEmpty: Boolean
     Checks if this set is empty.
protected var set: Set[A]
  def size: Int
     Returns the number of elements in this set.
override def toList: List[A]
     Returns the elements of this set as a list.
override def toString(): String
     Returns a string representation of this set.

Methods inherited from java/lang/Object-class
eq, finalize, getClass, ne, notify, notifyAll, synchronized, wait, wait, wait

Methods inherited from scala/Any-class
!=, ==, asInstanceOf, isInstanceOf, match

Methods inherited from scala/Iterable-class
/:, :\, concat, find, foldLeft, foldRight, forall, sameElements

Methods inherited from scala/ScalaObject-class
getScalaType

Methods inherited from scala/collection/Set-class
apply, equals, subsetOf

Methods inherited from scala/collection/mutable/Set-class
++=, ++=, --=, --=, <<, clone, excl, filter, hashCode, incl, intersect, update

Method Detail

set

  protected var set: Set[A]

size

  def size: Int
Returns the number of elements in this set.
Returns:
number of set elements.

isEmpty

  override def isEmpty: Boolean
Checks if this set is empty.
Returns:
true, iff there is no element in the set.

contains

  def contains(elem: A): Boolean
Checks if this set contains element elem.
Parameters:
elem - the element to check for membership.
Returns:
true, iff elem is contained in this set.

foreach

  override def foreach(f: (A) => Unit): Unit
Apply a function f to all elements of this iterable object.
Parameters:
f - a function that is applied to every element.

exists

  override def exists(p: (A) => Boolean): Boolean
Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
Parameters:
p - the predicate
Returns:
true, iff the predicate yields true for at least one element.

toList

  override def toList: List[A]
Returns the elements of this set as a list.
Returns:
a list containing all set elements.

toString

  override def toString(): String
Returns a string representation of this set.
Returns:
a string showing all elements of this set.

elements

  def elements: Iterator[A]
Creates a new iterator over all elements contained in this object.
Returns:
the new iterator

+=

  def +=(elem: A): Unit
This method adds a new element to the set.

-=

  def -=(elem: A): Unit
-= can be used to remove a single element from a set.

clear

  def clear: Unit
Removes all elements from the set. After this operation is completed, the set will be empty.

empty

  protected def empty: Set[A]