Set
case Set(RedBlackTree[t, Unit])
The Set type.
A set is currently represented internally as a red-black tree.
Instances
instance Collectable[Set[a]] with Order[a]
Sourceinstance CommutativeMonoid[Set[a]] with Order[a]
Sourceinstance CommutativeSemiGroup[Set[a]] with Order[a]
Sourceinstance JoinLattice[Set[a]] with Order[a]
Sourceinstance LowerBound[Set[a]]
Sourceinstance MeetLattice[Set[a]] with Order[a]
Sourceinstance PartialOrder[Set[a]] with Order[a]
Sourceinstance UnorderedFoldable[Set]
SourceDefinitions
@ParallelWhenPure
def count(f: a -> Bool \ ef, s: Set[a]): Int32 \ ef
SourceReturns the number of elements in s
that satisfy the predicate f
.
Purity reflective: Runs in parallel when given a pure function f
.
Returns the difference of s1
and s2
, i.e. s1 - s2
.
def empty(): Set[a]
SourceReturns the empty set.
Set#{}
is syntactic sugar for empty
i.e. Set#{} == empty()
.
def enumerator(rc: Region[r], s: Set[a]): Iterator[(Int32, a), r, r] \ r
SourceReturns an iterator over s
zipped with the indices of the elements.
def exists(f: a -> Bool \ ef, s: Set[a]): Bool \ ef
SourceReturns true
if and only if at least one element in s
satisfies the predicate f
.
Returns false
if s
is the empty set.
Returns the set of all elements of s
that satisfy the predicate f
.
Collects the results of applying the partial function f
to every element in s
.
def find(f: a -> Bool \ ef, s: Set[a]): Option[a] \ ef
SourceAlias for findLeft
.
def findLeft(f: a -> Bool \ ef, s: Set[a]): Option[a] \ ef
SourceOptionally returns the first element of s
that satisfies the predicate f
when searching from left to right.
def findRight(f: a -> Bool \ ef, s: Set[a]): Option[a] \ ef
SourceOptionally returns the first element of s
that satisfies the predicate f
when searching from right to left.
Returns the result of applying f
to every element in s
and taking the union.
Returns the result of applying combine
to all the elements in s
, using empty
as the initial value.
def foldLeft(f: b -> (a -> b \ ef), s: b, s1: Set[a]): b \ ef
SourceApplies f
to a start value s
and all elements in s
going from left to right.
That is, the result is of the form: f(...f(f(s, x1), x2)..., xn)
.
Returns the result of mapping each element and combining the results.
def foldRight(f: a -> (b -> b \ ef), s: b, s1: Set[a]): b \ ef
SourceApplies f
to a start value s
and all elements in s1
going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...)
.
def foldRightWithCont(f: a -> ((Unit -> b \ ef) -> b \ ef), z: b, s: Set[a]): b \ ef
SourceApplies f
to a start value z
and all elements in s
going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...)
.
A foldRightWithCont
allows early termination by not calling the continuation.
def forAll(f: a -> Bool \ ef, s: Set[a]): Bool \ ef
SourceReturns true
if and only if all elements in s
satisfy the predicate f
.
Returns true
if s
is the empty set.
def forEach(f: a -> Unit \ ef, s: Set[a]): Unit \ ef
SourceApplies f
to every element of s
.
def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), s: Set[a]): Unit \ ef
SourceApplies f
to every element of s
along with that element's index.
Returns the intersection of s1
and s2
.
def isEmpty(s: Set[a]): Bool
SourceReturns true if and only if s
is the empty set.
Returns true if and only if every element in s1
appears in s2
and s != s2
.
Returns true if and only if every element in s1
appears in s2
.
def iterator(rc: Region[r], s: Set[a]): Iterator[a, r, r] \ r
SourceReturns an iterator over s
.
Returns the concatenation of the string representation
of each element in s
with sep
inserted between each element.
def joinWith(f: a -> String \ ef, sep: String, s: Set[a]): String \ ef
SourceReturns the concatenation of the string representation
of each element in s
according to f
with sep
inserted between each element.
Returns the result of applying f
to every element in s
.
Note: The returned set may be smaller than s
.
def maximum(s: Set[a]): Option[a]
SourceOptionally finds the largest element of s
according to the Order
on a
.
Returns None
if s
is empty.
@ParallelWhenPure
def maximumBy(cmp: a -> (a -> Comparison \ ef), s: Set[a]): Option[a] \ ef
SourceOptionally finds the largest element of s
according to the given comparator cmp
.
Returns None
if s
is empty.
Purity reflective: Runs in parallel when given a pure function f
.
Returns true if and only if x
is a member of s
.
def minimum(s: Set[a]): Option[a]
SourceOptionally finds the smallest element of s
according to the Order
on a
.
Returns None
if s
is empty.
@ParallelWhenPure
def minimumBy(cmp: a -> (a -> Comparison \ ef), s: Set[a]): Option[a] \ ef
SourceOptionally finds the smallest element of s
according to the given comparator cmp
.
Returns None
if s
is empty.
Purity reflective: Runs in parallel when given a pure function f
.
def nonEmpty(s: Set[a]): Bool
SourceReturns true if and only if s
is a non-empty set.
Returns a pair of sets (s1, s2)
.
s1
contains all elements of s
that satisfy the predicate f
.
s2
contains all elements of s
that do not satisfy the predicate f
.
def range(b: Int32, e: Int32): Set[Int32]
SourceReturns a set of all integers between b
(inclusive) and e
(exclusive).
Returns empty()
if b >= e
.
def reduceLeft(f: a -> (a -> a \ ef), s: Set[a]): Option[a] \ ef
SourceApplies f
to all elements in s
going from left to right until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(...f(f(x1, x2), x3)..., xn))
Returns None
if s
is the empty set.
def reduceRight(f: a -> (a -> a \ ef), s: Set[a]): Option[a] \ ef
SourceApplies f
to all elements in s
going from right to left until a single value v
is obtained. Returns Some(v)
.
That is, the result is of the form: Some(f(x1, ...f(xn-2, f(xn-1, xn))...))
Returns None
if s
is the empty set.
Replaces the element src
with dst
if src
is in s
. Otherwise, returns s
.
Note: The returned set may be smaller than s
.
Returns the singleton set containing x
.
Set#{x}
is syntactic sugar for singleton
i.e. Set#{x} == singleton(x)
.
def size(s: Set[a]): Int32
SourceReturns the number of elements in s
.
def sum(s: Set[Int32]): Int32
SourceReturns the sum of all elements in the set s
.
@ParallelWhenPure
def sumWith(f: a -> Int32 \ ef, s: Set[a]): Int32 \ ef
SourceReturns the sum of all elements in the set s
according to the function f
.
Purity reflective: Runs in parallel when given a pure function f
.
def toArray(rc: Region[r], s: Set[a]): Array[a, r] \ r
SourceReturns the set s
as an array.
def toChain(s: Set[a]): Chain[a]
SourceReturns the set s
as a chain.
def toDelayList(s: Set[a]): DelayList[a]
SourceReturns the set s
as a DelayList
.
def toList(s: Set[a]): List[a]
SourceReturns the set s
as a list.
Returns the association set s
as a map.
If s
contains multiple mappings with the same key, toMap
does not
make any guarantees about which mapping will be in the resulting map.
Returns a map with elements of s
as keys and f
applied as values.
def toMutDeque(rc: Region[r], s: Set[a]): MutDeque[a, r] \ r
SourceReturns s
as a MutDeque.
def toMutSet(rc: Region[r], s: Set[a]): MutSet[a, r] \ r
SourceReturns the set s
as a MutSet
.
Returns a string representation of the given set s
.
def toVector(s: Set[a]): Vector[a]
SourceReturns the set s
as a vector.
Build a set by applying f
to the seed value st
.
f
should return Some(a,st1)
to signal a new set element a
and a new seed value st1
.
f
should return None
to signal the end of building the set.
Build a set by applying the function next
to ()
. next
is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next
should return Some(a)
to signal a value pair a
.
next
should return None
to signal the end of building the set.