|
|
|
|
|
Description |
|
|
Synopsis |
|
|
|
|
MultiSet type
|
|
|
|
|
Operators
|
|
|
O(n+m). See difference.
|
|
Query
|
|
|
O(1). Is the multi set empty?
|
|
|
O(n). The number of elements in the multi set.
|
|
|
O(1). Returns the number of distinct elements in the multi set, ie. (distinctSize mset == Set.size (toSet mset)).
|
|
|
O(log n). Is the element in the multi set?
|
|
|
O(log n). The number of occurrences of an element in the multi set.
|
|
|
O(n+m). Is this a subset of the multi set?
|
|
|
O(n+m). Is this a proper subset? (ie. a subset and not equal)
|
|
Construction
|
|
|
O(1). Create an empty multi set.
|
|
|
O(1). Create a singleton multi set.
|
|
|
O(log n). Insert an element in the multi set.
|
|
|
O(min(n,W)). The expression (insertMany x count mset)
inserts count instances of x in the multi set mset.
|
|
|
O(log n). Delete a single element.
|
|
|
O(log n). Delete all occurrences of an element.
|
|
Combine
|
|
|
O(n+m). Union of two multisets. The union adds the elements together.
MultiSet\> union (fromList [1,1,2]) (fromList [1,2,2,3])
{1,1,1,2,2,2,3}
|
|
|
O(n+m). Difference between two multisets.
MultiSet\> difference (fromList [1,1,2]) (fromList [1,2,2,3])
{1}
|
|
|
O(n+m). Intersection of two multisets.
MultiSet\> intersection (fromList [1,1,2]) (fromList [1,2,2,3])
{1,2}
|
|
|
The union of a list of multisets.
|
|
Filter
|
|
|
O(n). Filter all elements that satisfy some predicate.
|
|
|
O(n). Partition the multi set according to some predicate.
|
|
Fold
|
|
|
O(n). Fold over each element in the multi set.
|
|
|
O(n). Fold over all occurrences of an element at once.
|
|
Min/Max
|
|
|
O(log n). The minimal element of a multi set.
|
|
|
O(log n). The maximal element of a multi set.
|
|
|
O(log n). Delete the minimal element.
|
|
|
O(log n). Delete the maximal element.
|
|
|
O(log n). Delete all occurrences of the minimal element.
|
|
|
O(log n). Delete all occurrences of the maximal element.
|
|
Conversion
|
|
|
O(n). The list of elements.
|
|
List
|
|
|
O(n). Create a list with all elements.
|
|
|
O(n*log n). Create a multi set from a list of elements.
|
|
Ordered list
|
|
|
O(n). Create an ascending list of all elements.
|
|
|
O(n). Create a multi set from an ascending list in linear time.
|
|
|
O(n). Create a multi set from an ascending list of distinct elements in linear time.
|
|
Occurrence lists
|
|
|
O(n). Create a list of element/occurrence pairs.
|
|
|
O(n). Create an ascending list of element/occurrence pairs.
|
|
|
O(n*log n). Create a multi set from a list of element/occurrence pairs.
|
|
|
O(n). Create a multi set from an ascending list of element/occurrence pairs.
|
|
Map
|
|
|
O(1). Convert to a Map.Map from elements to number of occurrences.
|
|
|
O(n). Convert a Map.Map from elements to occurrences into a multi set.
|
|
|
O(1). Convert a Map.Map from elements to occurrences into a multi set.
Assumes that the Map.Map contains only elements that occur at least once.
|
|
Debugging
|
|
|
O(n). Show the tree structure that implements the MultiSet. The tree
is shown as a compressed and hanging.
|
|
|
O(n). The expression (showTreeWith hang wide map) shows
the tree that implements the multi set. The tree is shown hanging when hang is True
and otherwise as a rotated tree. When wide is True an extra wide version
is shown.
|
|
|
O(n). Is this a valid multi set?
|
|
Produced by Haddock version 2.6.1 |