intset-imperative-0.1.0.0: An imperative integer set written in Haskell.

Safe HaskellNone
LanguageHaskell2010

Data.IntSet.Bounded.Imperative

Contents

Description

An imperative integer set written in Haskell.

See "Making Haskell as fast as C: Imperative programming in Haskell" for a more detailed discussion, https://deliquus.com/posts/2018-07-30-imperative-programming-in-haskell.html.

Synopsis

Types

data IntSet s Source #

A strict bounded integer set.

The set is very efficient when accessing elements within the bounds of the set. It uses a regular list to hold numbers outside of this range.

The type parameter s is determined by the monad the data structure lives in.

type IOIntSet = IntSet (PrimState IO) Source #

An IntSet inside the IO monad.

intSetMinBound :: IntSet s -> Word64 Source #

Get the minimum efficient bound of the integer set.

intSetMaxBound :: IntSet s -> Word64 Source #

Get the maximum efficient bound of the integer set.

Construction

empty Source #

Arguments

:: PrimMonad m 
=> Word64

Minimum bound of the integer set

-> Word64

Maximum bound of the integer set

-> m (IntSet (PrimState m)) 

Construct an empty integer set.

Insertion

insert :: PrimMonad m => IntSet (PrimState m) -> Word64 -> m () Source #

Insert the integer in a set.

Query

member :: PrimMonad m => IntSet (PrimState m) -> Word64 -> m Bool Source #

Is the integer in the set?

notMember :: PrimMonad m => IntSet (PrimState m) -> Word64 -> m Bool Source #

Is the integer not in the set?

Deletion

delete :: PrimMonad m => IntSet (PrimState m) -> Word64 -> m () Source #

Delete the integer from the set.