Scala Library
|
|
trait
MutableSetTemplate[A, +This <: MutableSetTemplate[A, This] with
Set[A]]
extends
SetTemplate[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
|
+
(elem1 : A, elem2 : A, elems : A*) : This
Adds two or more elements to this collection and returns
the collection itself.
|
override def
|
+
(elem : A) : This
Adds a single element to this collection and returns
the collection itself.
|
override def
|
++
(iter : Iterator[A]) : This
Adds a number of elements provided by an iterator 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.
|
abstract def
|
+=
(elem : A) : MutableSetTemplate[A, This]
Adds a new element to the set.
|
override def
|
-
(elem : A) : This
Removes a single element from this collection and returns
the collection itself.
|
override def
|
-
(elem1 : A, elem2 : A, elems : A*) : This
Removes two or more elements from this collection and returns
the collection itself.
|
override def
|
--
(iter : Traversable[A]) : This
Removes a number of elements provided by a traversible 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) : MutableSetTemplate[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 SetTemplate
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 SetTemplate | |
empty (abstract), contains (abstract), isEmpty, apply, intersect, &, **, union, |, diff, &~, subsetOf, equals, stringPrefix, toString |
Methods inherited from IterableTemplate | |
iterator (abstract), elements, foreach, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection |
Methods inherited from TraversableTemplate | |
thisCollection, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSequence, toSet, mkString, mkString, mkString, addString, addString, addString |
Methods inherited from AnyRef | |
getClass, hashCode, 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 SetTemplate
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
abstract
def
+=(elem : A) : MutableSetTemplate[A, This]
elem -
the element to be addedabstract
def
-=(elem : A) : MutableSetTemplate[A, This]
elem -
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 iterable 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
|
|