Set is an immutable collection with no duplicate values
When an element is joined to a Set, it is evaluated for uniqueness and the operation is ignored in case of duplicates.
Note: Set is a concrete single implementation of unique collection. There is no general "Set" interface, because its use is rare. If there is a need for more efficient "Set" functionality, create one with Collection.Mutable.noDuplicates. The result is faster, but is not thread safe.
- Source
- __.scala
Def
Join element
Join element
If given value does not exist in current collection, a new Set is created with this value
var set: Set[Int]=VOID
set = set.join(1).join(1).join(2).join(2).join(3).join(3)
set.stream.tp // Prints Stream(1, 2, 3)
- Source
- __.scala
Join stream of elements
Join stream of elements
Creates a Set with a stream of only unique elements joined in
var set: Set[Int]=VOID
set = set.joinAll(1 <> 5).joinAll(3 <> 8).joinAll(5 <> 10)
set.stream.sort.tp // Prints Stream(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
- Source
- __.scala
Stream elements
Stream elements
Returns a stream of all collection elements
Unless specifically defined, the order must be assumed as random
val c = Collection(1,3,5,7)
c.stream.tp
// Output
Stream(1, 3, 5, 7)
- Inherited from
- Collection
- Source
- __.scala