flix

0.55.0

Set

enum Set[t: Type] with SendableSource
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]Source
instance CommutativeMonoid[Set[a]] with Order[a]Source
instance CommutativeSemiGroup[Set[a]] with Order[a]Source
instance Eq[Set[a]] with Eq[a]Source
instance Foldable[Set]Source
instance Hash[Set[a]] with Hash[a]Source
instance Iterable[Set[a]]Source
instance JoinLattice[Set[a]] with Order[a]Source
instance LowerBound[Set[a]]Source
instance MeetLattice[Set[a]] with Order[a]Source
instance Monoid[Set[a]] with Order[a]Source
instance Order[Set[a]] with Order[a]Source
instance PartialOrder[Set[a]] with Order[a]Source
instance SemiGroup[Set[a]] with Order[a]Source
instance Sendable[Set[t]] with Sendable[t]Source
instance ToFlix[Set[a]] with Order[a]Source
instance ToJava[Set[a]] with Order[a]Source
instance ToString[Set[a]] with ToString[a]Source

Definitions

@ParallelWhenPure
def count(f: a -> Bool \ ef, s: Set[a]): Int32 \ ef Source

Returns the number of elements in s that satisfy the predicate f.

Purity reflective: Runs in parallel when given a pure function f.

def difference(s1: Set[a], s2: Set[a]): Set[a] with Order[a] Source

Returns the difference of s1 and s2, i.e. s1 - s2.

def empty(): Set[a] Source

Returns 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 Source

Returns an iterator over s zipped with the indices of the elements.

def exists(f: a -> Bool \ ef, s: Set[a]): Bool \ ef Source

Returns true if and only if at least one element in s satisfies the predicate f.

Returns false if s is the empty set.

def filter(f: a -> Bool \ ef, s: Set[a]): Set[a] \ ef with Order[a] Source

Returns the set of all elements of s that satisfy the predicate f.

def filterMap(f: a -> Option[b] \ ef, s: Set[a]): Set[b] \ ef with Order[b] Source

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 Source

Alias for findLeft.

def findLeft(f: a -> Bool \ ef, s: Set[a]): Option[a] \ ef Source

Optionally 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 Source

Optionally returns the first element of s that satisfies the predicate f when searching from right to left.

def flatMap(f: a -> Set[b] \ ef, s: Set[a]): Set[b] \ ef with Order[b] Source

Returns the result of applying f to every element in s and taking the union.

def flatten(s: Set[Set[a]]): Set[a] with Order[a] Source

Returns the union of the elements in s.

def fold(s: Set[a]): a with Monoid[a] Source

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 Source

Applies 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).

def foldMap(f: a -> b \ ef, s: Set[a]): b \ ef with Monoid[b] Source

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 Source

Applies 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 Source

Applies 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 Source

Returns 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 Source

Applies f to every element of s.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), s: Set[a]): Unit \ ef Source

Applies f to every element of s along with that element's index.

def insert(x: a, s: Set[a]): Set[a] with Order[a] Source

Adds x to s.

def intersection(s1: Set[a], s2: Set[a]): Set[a] with Order[a] Source

Returns the intersection of s1 and s2.

def isEmpty(s: Set[a]): Bool Source

Returns true if and only if s is the empty set.

def isProperSubsetOf(s1: Set[a], s2: Set[a]): Bool with Order[a] Source

Returns true if and only if every element in s1 appears in s2 and s != s2.

def isSubsetOf(s1: Set[a], s2: Set[a]): Bool with Order[a] Source

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 Source

Returns an iterator over s.

def join(sep: String, s: Set[a]): String with ToString[a] Source

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 Source

Returns the concatenation of the string representation of each element in s according to f with sep inserted between each element.

def map(f: a -> b \ ef, s: Set[a]): Set[b] \ ef with Order[b] Source

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] Source

Optionally 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 Source

Optionally 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.

def memberOf(x: a, s: Set[a]): Bool with Order[a] Source

Returns true if and only if x is a member of s.

def minimum(s: Set[a]): Option[a] Source

Optionally 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 Source

Optionally 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 Source

Returns true if and only if s is a non-empty set.

def partition(f: a -> Bool \ ef, s: Set[a]): (Set[a], Set[a]) \ ef with Order[a] Source

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] Source

Returns 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 Source

Applies 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 Source

Applies 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.

def remove(x: a, s: Set[a]): Set[a] with Order[a] Source

Removes x from s.

def replace(src: { src = a }, dst: { dst = a }, s: Set[a]): Set[a] with Order[a] Source

Replaces the element src with dst if src is in s. Otherwise, returns s.

Note: The returned set may be smaller than s.

def singleton(x: a): Set[a] with Order[a] Source

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 Source

Returns the number of elements in s.

def subsets(s: Set[a]): Set[Set[a]] with Order[a] Source

Returns all subsets of s.

def sum(s: Set[Int32]): Int32 Source

Returns the sum of all elements in the set s.

@ParallelWhenPure
def sumWith(f: a -> Int32 \ ef, s: Set[a]): Int32 \ ef Source

Returns 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 Source

Returns the set s as an array.

def toChain(s: Set[a]): Chain[a] Source

Returns the set s as a chain.

def toDelayList(s: Set[a]): DelayList[a] Source

Returns the set s as a DelayList.

def toList(s: Set[a]): List[a] Source

Returns the set s as a list.

def toMap(s: Set[(a, b)]): Map[a, b] with Order[a] Source

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.

def toMapWith(f: a -> b, s: Set[a]): Map[a, b] with Order[a] Source

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 Source

Returns s as a MutDeque.

def toMutSet(rc: Region[r], s: Set[a]): MutSet[a, r] \ r Source

Returns the set s as a MutSet.

def toString(s: Set[a]): String with ToString[a] Source

Returns a string representation of the given set s.

def toVector(s: Set[a]): Vector[a] Source

Returns the set s as a vector.

def unfold(f: s -> Option[(a, s)] \ ef, st: s): Set[a] \ ef with Order[a] Source

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.

def unfoldWithIter(next: Unit -> Option[a] \ ef): Set[a] \ ef with Order[a] Source

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.

def union(s1: Set[a], s2: Set[a]): Set[a] with Order[a] Source

Returns the union of s1 and s2.