| ||||||||

| ||||||||

| ||||||||

Description | ||||||||

An efficient implementation of integer sets. Since many function names (but not the type name) clash with
Prelude names, this module is usually imported import Data.IntSet (IntSet) import qualified Data.IntSet as IntSet The implementation is based on - Chris Okasaki and Andy Gill, "
*Fast Mergeable Integer Maps*", Workshop on ML, September 1998, pages 77-86, http://citeseer.ist.psu.edu/okasaki98fast.html - D.R. Morrison, "/PATRICIA -- Practical Algorithm To Retrieve Information Coded In Alphanumeric/", Journal of the ACM, 15(4), October 1968, pages 514-534.
Many operations have a worst-case complexity of | ||||||||

Synopsis | ||||||||

Set type | ||||||||

| ||||||||

| ||||||||

Operators | ||||||||

| ||||||||

O(n+m). See difference.
| ||||||||

Query | ||||||||

| ||||||||

O(1). Is the set empty?
| ||||||||

| ||||||||

O(n). Cardinality of the set.
| ||||||||

| ||||||||

O(min(n,W)). Is the value a member of the set?
| ||||||||

| ||||||||

O(min(n,W)). Is the element not in the set?
| ||||||||

| ||||||||

O(n+m). Is this a subset?
(s1 tells whether isSubsetOf s2)s1 is a subset of s2.
| ||||||||

| ||||||||

O(n+m). Is this a proper subset? (ie. a subset but not equal).
| ||||||||

Construction | ||||||||

| ||||||||

O(1). The empty set.
| ||||||||

| ||||||||

O(1). A set of one element.
| ||||||||

| ||||||||

O(min(n,W)). Add a value to the set. When the value is already
an element of the set, it is replaced by the new one, ie. insert
is left-biased.
| ||||||||

| ||||||||

O(min(n,W)). Delete a value in the set. Returns the
original set when the value was not present.
| ||||||||

Combine | ||||||||

| ||||||||

O(n+m). The union of two sets.
| ||||||||

| ||||||||

The union of a list of sets. | ||||||||

| ||||||||

O(n+m). Difference between two sets.
| ||||||||

| ||||||||

O(n+m). The intersection of two sets.
| ||||||||

Filter | ||||||||

| ||||||||

O(n). Filter all elements that satisfy some predicate.
| ||||||||

| ||||||||

O(n). partition the set according to some predicate.
| ||||||||

| ||||||||

(set1,set2)
where set1 comprises the elements of set less than x and set2
comprises the elements of set greater than x.
split 3 (fromList [1..5]) == (fromList [1,2], fromList [4,5]) | ||||||||

| ||||||||

O(min(n,W)). Performs a split but also returns whether the pivot
element was found in the original set.
| ||||||||

Min/Max | ||||||||

| ||||||||

O(min(n,W)). The minimal element of a set.
| ||||||||

| ||||||||

O(min(n,W)). The maximal element of a set.
| ||||||||

| ||||||||

O(min(n,W)). Delete the minimal element.
| ||||||||

| ||||||||

O(min(n,W)). Delete the maximal element.
| ||||||||

| ||||||||

deleteFindMin set = (findMin set, deleteMin set) | ||||||||

| ||||||||

deleteFindMax set = (findMax set, deleteMax set) | ||||||||

| ||||||||

O(min(n,W)). Retrieves the maximal key of the set, and the set
stripped of that element, or Nothing if passed an empty set.
| ||||||||

| ||||||||

O(min(n,W)). Retrieves the minimal key of the set, and the set
stripped of that element, or Nothing if passed an empty set.
| ||||||||

Map | ||||||||

| ||||||||

f to each element of s.
It's worth noting that the size of the result may be smaller if,
for some | ||||||||

Fold | ||||||||

| ||||||||

sum set == fold (+) 0 set elems set == fold (:) [] set | ||||||||

Conversion | ||||||||

List | ||||||||

| ||||||||

O(n). The elements of a set. (For sets, this is equivalent to toList)
| ||||||||

| ||||||||

O(n). Convert the set to a list of elements.
| ||||||||

| ||||||||

O(n*min(n,W)). Create a set from a list of integers.
| ||||||||

Ordered list | ||||||||

| ||||||||

O(n). Convert the set to an ascending list of elements.
| ||||||||

| ||||||||

O(n*min(n,W)). Build a set from an ascending list of elements.
| ||||||||

| ||||||||

O(n*min(n,W)). Build a set from an ascending list of distinct elements.
| ||||||||

Debugging | ||||||||

| ||||||||

O(n). Show the tree that implements the set. The tree is shown
in a compressed, hanging format.
| ||||||||

| ||||||||

O(n). The expression () shows
the tree that implements the set. If showTreeWith hang wide maphang is
True, a hanging tree is shown otherwise a rotated tree is shown. If
wide is True, an extra wide version is shown.
| ||||||||

Produced by Haddock version 2.4.2 |