-
Effekt Library
- set
- Set
- empty
- emptyGeneric
- isEmpty
- nonEmpty
- singleton
- singletonGeneric
- size
- insert
- fromMapKeys
- toMap
- fromList
- fromListGeneric
- foreach
- toList
- all
- any
- contains
- subset
- superset
- delete
- deleteMany
- difference
- difference
- union
- union
- intersection
- intersection
- each
- collect
- returning
- collect
- set Jump to source: libraries/common/set.effekt
- Set
[A] (tree: Tree[A, Unit], compare: (A, A) => Ordering at {}) - empty
[A] (compare: (A, A) => Ordering at {}): Set[A] / {} - emptyGeneric
[A]: Set[A] / {} - isEmpty
[A] (s: Set[A]): Bool / {} - nonEmpty
[A] (s: Set[A]): Bool / {} - singleton
[A] (element: A, compare: (A, A) => Ordering at {}): Set[A] / {} - singletonGeneric
[A] (element: A): Set[A] / {} - size
[A] (s: Set[A]): Int / {} - insert
[A] (s: Set[A], a: A): Set[A] / {} - fromMapKeys
[K, V] (map: Map[K, V]): Set[K] / {} - toMap
[K, V] (keys: Set[K]) { valueOf: (K) => V }: Map[K, V] / {} - fromList
[A] (list: List[A], compare: (A, A) => Ordering at {}): Set[A] / {} - fromListGeneric
[A] (list: List[A]): Set[A] / {} - foreach
[A] (s: Set[A]) { action: (A) => Unit }: Unit / {} - toList
[A] (s: Set[A]): List[A] / {} - all
[A] (s: Set[A]) { predicate: (A) => Bool }: Bool / {} - any
[A] (s: Set[A]) { predicate: (A) => Bool }: Bool / {} - contains
[A] (s: Set[A], a: A): Bool / {} - subset
[A] (s1: Set[A], s2: Set[A]): Bool / {} - superset
[A] (s1: Set[A], s2: Set[A]): Bool / {} - delete
[A] (s: Set[A], a: A): Set[A] / {} - deleteMany
[A] (s: Set[A], list: List[A]): Set[A] / {} - difference
[A] (s1: Set[A], s2: Set[A], compare: (A, A) => Ordering at {}): Set[A] / {} - difference
[A] (s1: Set[A], s2: Set[A]): Set[A] / {} - union
[A] (s1: Set[A], s2: Set[A], compare: (A, A) => Ordering at {}): Set[A] / {} - union
[A] (s1: Set[A], s2: Set[A]): Set[A] / {} - intersection
[A] (s1: Set[A], s2: Set[A], compare: (A, A) => Ordering at {}): Set[A] / {} - intersection
[A] (s1: Set[A], s2: Set[A]): Set[A] / {} - each
[A] (set: Set[A]): Unit / {emit[A]} - collect
[A] (compare: (A, A) => Ordering at {}) { stream: => Unit / {emit[A]} }: Set[A] / {} - returning
- collect
[A, R] (compare: (A, A) => Ordering at {}) { stream: => R / {emit[A]} }: Tuple2[R, Set[A]] / {}
Example usage: examples/stdlib/set
Ordered finite immutable set, backed by balanced binary trees of logarithmic depth.
Create a new empty set using a pure, first-class comparison function. O(1)
Create a new empty set using a generic comparison function. Only available on JavaScript backends! O(1)
Check if set `s` is empty. O(1)
Check if set `s` is nonempty. O(1)
Create a new set containing a single `element`. Requires a pure, first-class comparison function. O(1)
Create a new set containing a single `element` and a generic comparison function. Only available on the JavaScript backends! O(1)
Get the size of the set (the number of its elements). O(1)
Insert a new element `a` into the set `s`. O(log N)
Create a set from a given map by ignoring the values. O(N)
Create a map from a set and a function, reusing the set's comparison. O(N)
Create a set from a given list and a pure, first-class comparison function. O(N log N) O(N) if the list is sorted
Create a set from a given list with a generic comparison function. Works only on the JavaScript backends! O(N log N) O(N) if the list is sorted
Traverse all elements in order, running the function `action` on each element.
Law: `s.foreach { action } === s.toList.foreach { action }`
O(N)Create a list from a given set. O(N)
Check if a predicate holds for all elements in a given set. O(N)
Check if a predicate holds for at least one element in a given set. O(N)
Check if a set contains a given element. O(log N)
Check if set `s1` is a subset of set `s2`. O(N log N)
Check if set `s1` is a superset of set `s2`. O(N log N)
Remove an element from a set. If the element is not in the set, the original set is returned. O(log N)
Remove many elements from a set. O(M log N) where M is the size of the list.
Construct a new set which contains all elements of `s1` except those where the element is in `s2`. Uses an explicit comparison function. O(???)
Construct a new set which contains all elements of `s1` except those where the element is in `s2`. Uses a comparison function from `s1`. O(???)
Construct a new set which contains both elements of `s1` and `s2`. Uses an explicit comparison function. O(???)
Construct a new set which contains both elements of `s1` and `s2`. Uses a comparison function from `s1`. O(???)
Construct a new set which contains only elements which are in both of `s1` and `s2`. Uses an explicit comparison function. O(???)
Construct a new set which contains only elements which are in both of `s1` and `s2`. Uses a comparison function from `s1`. O(???)
Turns a `set` into a producer of a push stream by emitting each contained *in order*.