Scala Library
|
|
scala/collection/Set.scala
]
trait
Set[A]
extends
(A) => Boolean with
Collection[A]A set is a collection that includes at most one of any object.
This trait provides a limited interface, only allowing reading of elements.
There are two extensions of this trait, in packages
scala.collection.mutable
and
scala.collection.immutable
, which provide functionality for
adding and removing objects from the set. The trait in the first package is
for sets that are modified destructively, whereas the trait in
the second package is for immutable sets which create a new set
when something is added or removed to them.
Method Summary | |
def
|
* (that : Set[A]) : Set[A] |
def
|
**
(that : Set[A]) : Set[A]
Intersect. It computes an intersection with set
that .
It removes all the elements that are not present in that . |
def
|
apply
(elem : A) : Boolean
This method allows sets to be interpreted as predicates.
It returns
true , iff this set contains element
elem . |
abstract def
|
contains
(elem : A) : Boolean
Checks if this set contains element
elem . |
override def
|
equals
(that : Any) : Boolean
Compares this set with another object and returns true, iff the
other object is also a set which contains the same elements as
this set.
|
override def
|
hashCode
: Int
Returns a hash code value for the object.
|
override def
|
isEmpty
: Boolean
Checks if this set is empty.
|
abstract def
|
size
: Int
Returns the number of elements in this set.
|
protected override def
|
stringPrefix
: java.lang.String
Defines the prefix of this object's
toString representation. |
def
|
subsetOf
(that : Set[A]) : Boolean
Checks if this set is a subset of set
that . |
override def
|
toArray
[B >: A] : Array[B]
Converts this iterable to a fresh Array with elements.
|
Methods inherited from Collection | |
toString |
Methods inherited from Iterable | |
elements (abstract), concat, ++, map, flatMap, filter, partition, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toSeq, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, projection, hasDefiniteSize |
Methods inherited from Function1 | |
compose, andThen |
Methods inherited from AnyRef | |
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
abstract
def
size : Int
elem
.elem -
the element to check for membership.true
iff elem
is contained in this set.true
, iff this set contains element
elem
.elem -
the element to check for membership.true
iff elem
is contained in this set.override
def
isEmpty : Boolean
true
iff there is no element in the set.that
.that -
another set.true
iff the other set is a superset of this set.
todo: rename to isSubsetOf
def
*(that : Set[A]) : Set[A]
that
.
It removes all the elements that are not present in that
.that -
the set to intersect withthat -
the other objecttrue
iff this set and the other set contain the same elements.override
def
hashCode : Int
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash
codes (o1.hashCode.equals(o2.hashCode)
) yet not be
equal (o1.equals(o2)
returns false
). A
degenerate implementation could always return 0
.
However, it is required that if two objects are equal
(o1.equals(o2)
returns true
) that they
have identical hash codes
(o1.hashCode.equals(o2.hashCode)
). Therefore, when
overriding this method, be sure to verify that the behavior is
consistent with the equals
method.
protected override
def
stringPrefix : java.lang.String
toString
representation.
Scala Library
|
|