|
Scala Library
|
|
scala/collection/mutable/SetLike.scala]
trait
SetLike[A, +This <: SetLike[A, This] with Set[A]]
extends SetLike[A, This] with Scriptable[A] with Builder[A, This] with Shrinkable[A] with Cloneable[Set[A]]
A generic template for mutable sets of elements of type A.
To implement a concrete mutable set, you need to provide implementations
of the following methods:
def contains(elem: A): Boolean
def iterator: Iterator[A]
def += (elem: A): this.type
def -= (elem: A): this.type
If you wish that methods like, take,
drop, filter return the same kind of map,
you should also override:
def empty: This
It is also good idea to override methods foreach and
size for efficiency.
| Method Summary | |
override def
|
+
(elem : A) : This
Adds a single element to this collection and returns
the collection itself.
|
override def
|
+
(elem1 : A, elem2 : A, elems : A*) : This
Adds two or more elements to this collection and returns
the collection itself.
|
override def
|
++
(iter : Traversable[A]) : This
Adds a number of elements provided by a traversable object and returns
either the collection itself.
|
override def
|
++
(iter : Iterator[A]) : This
Adds a number of elements provided by an iterator and returns
the collection itself.
|
abstract def
|
+=
(elem : A) : SetLike[A, This]
Adds a new element to the set.
|
override def
|
-
(elem1 : A, elem2 : A, elems : A*) : This
Removes two or more elements from this collection and returns
the collection itself.
|
override def
|
-
(elem : A) : This
Removes a single element from this collection and returns
the collection itself.
|
override def
|
--
(iter : Traversable[A]) : This
Removes a number of elements provided by a Traversable object and returns
the collection itself.
|
override def
|
--
(iter : Iterator[A]) : This
Removes a number of elements provided by an iterator and returns
the collection itself.
|
abstract def
|
-=
(elem : A) : SetLike[A, This]
Removes a single element from a set.
|
def
|
<<
(cmd : Message[A]) : Unit
Send a message to this scriptable object.
|
def
|
add
(elem : A) : Boolean
Adds a new element to the set.
|
def
|
clear
: Unit
Removes all elements from the set. After this operation is completed,
the set will be empty.
|
override def
|
clone
: Set[A]
This method creates and returns a copy of the receiver object.
|
protected[this] override def
|
newBuilder
: Builder[A, This]
A common implementation of
newBuilder for all mutable sets
in terms of empty. Overrides SetLike
implementation for better efficiency. |
def
|
remove
(elem : A) : Boolean
Removes a single element from a set.
|
def
|
result
: This
Returns collection resulting from this builder. The buffer's contents
are undefined afterwards.
|
def
|
retain
(p : (A) => Boolean) : Unit
Removes all elements from the set for which the predicate
p
yields the value false. |
def
|
update
(elem : A, included : Boolean) : Unit
This method allows one to add or remove an element
elem
from this set depending on the value of parameter included.
Typically, one would use the following syntax:
set(elem) = true |
| Methods inherited from Shrinkable | |
| -=, --=, --= |
| Methods inherited from Builder | |
| sizeHint, mapResult |
| Methods inherited from Growable | |
| +=, ++=, ++= |
| Methods inherited from SetLike | |
| empty (abstract), contains (abstract), isEmpty, apply, intersect, &, **, union, |, diff, &~, subsetOf, stringPrefix, toString, hashCode, equals |
| Methods inherited from IterableLike | |
| iterator (abstract), thisCollection, toCollection, elements, foreach, forall, exists, find, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, view, view, first, firstOption, projection |
| Methods inherited from TraversableLike | |
| repr, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toSeq, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, withFilter |
| Methods inherited from AnyRef | |
| getClass, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Method Details |
newBuilder for all mutable sets
in terms of empty. Overrides SetLike
implementation for better efficiency.elem - the element to be addedelem - The element to be removed.elem
from this set depending on the value of parameter included.
Typically, one would use the following syntax:
set(elem) = true
elem - the element to be addedelem - The element to be removed.p
yields the value false.
def
clear : Unit
The default implementation of the clone method is platform dependent.
def
result : This
override
def
+(elem : A) : This
elem - the element to add.override
def
+(elem1 : A, elem2 : A, elems : A*) : This
elem1 - the first element to add.elem2 - the second element to add.elems - the remaining elements to add.override
def
++(iter : Traversable[A]) : This
iter - the iterable object.override
def
++(iter : Iterator[A]) : This
iter - the iteratoroverride
def
-(elem : A) : This
elem - the element to remove.override
def
-(elem1 : A, elem2 : A, elems : A*) : This
elem1 - the first element to remove.elem2 - the second element to remove.elems - the remaining elements to remove.override
def
--(iter : Traversable[A]) : This
iter - the Traversable object.override
def
--(iter : Iterator[A]) : This
iter - the iteratorcmd - the message to send.<code>Predef.UnsupportedOperationException</code> - if the message was not understood.|
Scala Library
|
|