bitset-1.4.0: A space-efficient set data structure.

PortabilityGHC
Stabilityexperimental
Maintainersuperbobry@gmail.com
Safe HaskellNone

Data.BitSet.Dynamic

Contents

Description

A space-efficient implementation of set data structure for enumerated data types.

Note: Read below the synopsis for important notes on the use of this module.

This module is intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.

 import Data.BitSet.Dynamic (BitSet)
 import qualified Data.BitSet.Dynamic as BS

The implementation uses Integer as underlying container, thus it grows automatically when more elements are inserted into the bit set.

Synopsis

Bit set type

Operators

(\\) :: BitSet a -> BitSet a -> BitSet aSource

O(1). See difference.

Construction

empty :: Enum a => BitSet aSource

The empty bit set.

singleton :: Enum a => a -> BitSet aSource

O(1). Create a singleton set.

insert :: a -> BitSet a -> BitSet aSource

O(1). Insert an item into the bit set.

delete :: a -> BitSet a -> BitSet aSource

O(1). Delete an item from the bit set.

Query

null :: BitSet a -> BoolSource

O(1). Is the bit set empty?

size :: BitSet a -> IntSource

O(1). The number of elements in the bit set.

member :: Enum a => a -> BitSet a -> BoolSource

O(1). Ask whether the item is in the bit set.

notMember :: Enum a => a -> BitSet a -> BoolSource

O(1). Ask whether the item is in the bit set.

isSubsetOf :: BitSet a -> BitSet a -> BoolSource

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

isProperSubsetOf :: BitSet a -> BitSet a -> BoolSource

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

Combine

union :: BitSet a -> BitSet a -> BitSet aSource

O(max(m, n)). The union of two bit sets.

difference :: BitSet a -> BitSet a -> BitSet aSource

O(1). Difference of two bit sets.

intersection :: BitSet a -> BitSet a -> BitSet aSource

O(1). The intersection of two bit sets.

Transformations

map :: (Enum a, Enum b) => (a -> b) -> BitSet a -> BitSet bSource

O(n) Transform this bit set by applying a function to every value. Resulting bit set may be smaller then the original.

Folds

foldl' :: (b -> a -> b) -> b -> BitSet a -> bSource

O(n) Reduce this bit set by applying a binary function to all elements, using the given starting value. Each application of the operator is evaluated before before using the result in the next application. This function is strict in the starting value.

foldr :: (a -> b -> b) -> b -> BitSet a -> bSource

O(n) Reduce this bit set by applying a binary function to all elements, using the given starting value.

Filter

filter :: Enum a => (a -> Bool) -> BitSet a -> BitSet aSource

O(n) Filter this bit set by retaining only elements satisfying a predicate.

Lists

toList :: BitSet a -> [a]Source

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

fromList :: Enum a => [a] -> BitSet aSource

O(n). Make a bit set from a list of elements.