Collection.StableSet

abstract class StableSet[A] extends Collection[A] with Able.Contain[A]

StableSet is an immutable collection with no duplicate values

StableSet has global alias and can be called without parent prefix Collection.StableSet

When an elements is joined to StableSet, it is evaluated for uniqueness and the operation is ignored in case of duplicates.

Note: StableSet 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", create one with Collection.Mutable.uniqueElementSet. The result is faster, but not thread safe.

Source
StableSet.scala
trait Able.Contain[A]
trait Collection[A]
trait Able.Size
trait Able.~[A]
class java.lang.Object
trait scala.Matchable
class Any

Def

@scala.annotation.targetName("stream")
def ~: ~[A]

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.~.tp

  // Output
  ~(1, 3, 5, 7)
Inherited from
Collection
Source
__.scala
@scala.annotation.targetName("_join")
inline def +(inline v: A): this.type

Alias for join

Alias for join

If given value does not exist in current collection, a new StableSet is created with this value

 var set: StableSet[Int] = \/

 set = set + 1 + 2 + 3 + 1 + 2 + 3

 set.~.tp  // Prints ~(1, 2, 3)
Source
StableSet.scala
@scala.annotation.targetName("_joinAll")
inline def ++(inline v: ~[A]): this.type

Alias for joinAll

Alias for joinAll

Creates a StableSet with a stream of only unique elements joined in

 var set: StableSet[Int] = \/

 set = set ++ (1 <> 5) ++ (3 <> 8) ++ (5 <> 10)

 set.~.sort.tp  // Prints ~(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Source
StableSet.scala
def contains(v: A): Boolean
override def isEmpty: Boolean

Empty check

Empty check

Returns true if instance is empty.

Definition Classes
Inherited from
Size
Source
Size.scala
def join(v: A): this.type

Join element

Join element

If given value does not exist in current collection, a new StableSet is created with this value

 var set: StableSet[Int] = \/

 set = set.join(1).join(1).join(2).join(2).join(3).join(3)

 set.~.tp  // Prints ~(1, 2, 3)
Source
StableSet.scala
def joinAll(v: ~[A]): this.type

Join stream of elements

Join stream of elements

Creates a StableSet with a stream of only unique elements joined in

 var set: StableSet[Int] = \/

 set = set.joinAll(1 <> 5).joinAll(3 <> 8).joinAll(5 <> 10)

 set.~.sort.tp  // Prints ~(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Source
StableSet.scala
override def size: Int

Element count

Element count

Retuns element count

Definition Classes
Inherited from
Collection
Source
__.scala