scala.collection.mutable

class ImmutableSetAdaptor

[source: scala/collection/mutable/ImmutableSetAdaptor.scala]

@serializable

class ImmutableSetAdaptor[A](protected val set : Set[A])
extends Set[A]
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) : ImmutableSetAdaptor[A]
Adds a new element to the set.
def -= (elem : A) : ImmutableSetAdaptor[A]
Removes a single element from a set.
override def clear : Unit
Removes all elements from the set. After this operation is completed, the set will be empty.
def contains (elem : A) : Boolean
Checks if this set contains element elem.
override def elements : Iterator[A]
override def exists (p : (A) => Boolean) : Boolean
Return true iff there is an element in this traversable for which the given predicate `p` yields true.
override def foreach [U](f : (A) => U) : Unit
Apply a function f to all elements of this traversable object.
override def isEmpty : Boolean
Checks if this set is empty.
def iterator : Iterator[A]
Creates a new iterator over all elements contained in this iterable object.
override def size : Int
The number of elements in this collection
override def toList : List[A]
Returns a list with all elements of this traversable object.
override def toString : java.lang.String
Need to override string, so that it's not the Function1's string that gets mixed in.
Methods inherited from Set
companion
Methods inherited from Unhashable
hashCode, identityHashCode
Methods inherited from MutableSetTemplate
newBuilder, add, remove, update, retain, clone, result, +, +, ++, ++, -, -, --, --, <<
Methods inherited from Shrinkable
-=, --=, --=
Methods inherited from Builder
sizeHint, mapResult
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from SetTemplate
apply, intersect, &, **, union, |, diff, &~, subsetOf, equals, stringPrefix
Methods inherited from SetClass
empty
Methods inherited from Function1
compose, andThen
Methods inherited from IterableTemplate
foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection
Methods inherited from TraversableClass
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toSequence, toSet, mkString, mkString, mkString, addString, addString, addString
Methods inherited from AnyRef
getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override def size : Int
The number of elements in this collection

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

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.

override def foreach[U](f : (A) => U) : Unit
Apply a function f to all elements of this traversable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.

override def exists(p : (A) => Boolean) : Boolean
Return true iff there is an element in this traversable for which the given predicate `p` yields true.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate

override def toList : List[A]
Returns a list with all elements of this traversable object.
Notes
Will not terminate for infinite-sized collections.

override def toString : java.lang.String
Need to override string, so that it's not the Function1's string that gets mixed in.

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

@deprecated("use `iterator' instead")

override def elements : Iterator[A]

def +=(elem : A) : ImmutableSetAdaptor[A]
Adds a new element to the set.
Parameters
elem - the element to be added

def -=(elem : A) : ImmutableSetAdaptor[A]
Removes a single element from a set.
Parameters
elem - The element to be removed.

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