charset-0.3.7.1: Fast unicode character sets based on complemented PATRICIA tries

Copyright | (c) Edward Kmett 2010-2011
License | BSD3
Maintainer | ekmett@gmail.com
Stability | experimental
Portability | portable
Safe Haskell | Trustworthy
Language | Haskell98

Data.CharSet

Contents

- Set type
- Operators
- Query
- Construction
- Combine
- Filter
- Map
- Fold
- Conversion
  - List
  - Ordered list
  - IntMaps
  - Array

Description

Fast set membership tests for `Char` values

Stored as a (possibly negated) IntMap and a fast set used for the head byte.

The set of valid (possibly negated) head bytes is stored unboxed as a 32-byte bytestring-based lookup table.

Designed to be imported qualified:

    import Data.CharSet (CharSet)
    import qualified Data.CharSet as CharSet

Synopsis

- data CharSet = CharSet !Bool !ByteSet !IntSet
- (\\) :: CharSet -> CharSet -> CharSet
- null :: CharSet -> Bool
- size :: CharSet -> Int
- member :: Char -> CharSet -> Bool
- notMember :: Char -> CharSet -> Bool
- overlaps :: CharSet -> CharSet -> Bool
- isSubsetOf :: CharSet -> CharSet -> Bool
- isComplemented :: CharSet -> Bool
- build :: (Char -> Bool) -> CharSet
- empty :: CharSet
- singleton :: Char -> CharSet
- full :: CharSet
- insert :: Char -> CharSet -> CharSet
- delete :: Char -> CharSet -> CharSet
- complement :: CharSet -> CharSet
- range :: Char -> Char -> CharSet
- union :: CharSet -> CharSet -> CharSet
- intersection :: CharSet -> CharSet -> CharSet
- difference :: CharSet -> CharSet -> CharSet
- filter :: (Char -> Bool) -> CharSet -> CharSet
- partition :: (Char -> Bool) -> CharSet -> (CharSet, CharSet)
- map :: (Char -> Char) -> CharSet -> CharSet
- fold :: (Char -> b -> b) -> b -> CharSet -> b
- toList :: CharSet -> String
- fromList :: String -> CharSet
- toAscList :: CharSet -> String
- fromAscList :: String -> CharSet
- fromDistinctAscList :: String -> CharSet
- fromCharSet :: CharSet -> (Bool, IntSet)
- toCharSet :: IntSet -> CharSet
- toArray :: CharSet -> UArray Char Bool

# Set type

data CharSet Source

Constructors

CharSet !Bool !ByteSet !IntSet |

Instances

Bounded CharSet Source |
Eq CharSet Source |
Data CharSet Source |
Ord CharSet Source |
Read CharSet Source |
Show CharSet Source |
Monoid CharSet Source |
Semigroup CharSet Source |

# Operators

(\\) :: CharSet -> CharSet -> CharSet Source

# Query

null :: CharSet -> Bool Source

O(n) worst case

size :: CharSet -> Int Source

O(n)

member :: Char -> CharSet -> Bool Source

notMember :: Char -> CharSet -> Bool Source

overlaps :: CharSet -> CharSet -> Bool Source

isSubsetOf :: CharSet -> CharSet -> Bool Source

isComplemented :: CharSet -> Bool Source

# Construction

build :: (Char -> Bool) -> CharSet Source

empty :: CharSet Source

singleton :: Char -> CharSet Source

full :: CharSet Source

insert :: Char -> CharSet -> CharSet Source

delete :: Char -> CharSet -> CharSet Source

complement :: CharSet -> CharSet Source

range :: Char -> Char -> CharSet Source

# Combine

union :: CharSet -> CharSet -> CharSet Source

intersection :: CharSet -> CharSet -> CharSet Source

difference :: CharSet -> CharSet -> CharSet Source

# Filter

filter :: (Char -> Bool) -> CharSet -> CharSet Source

partition :: (Char -> Bool) -> CharSet -> (CharSet, CharSet) Source

# Map

map :: (Char -> Char) -> CharSet -> CharSet Source

# Fold

fold :: (Char -> b -> b) -> b -> CharSet -> b Source

# Conversion

## List

toList :: CharSet -> String Source

fromList :: String -> CharSet Source

## Ordered list

toAscList :: CharSet -> String Source

fromAscList :: String -> CharSet Source

fromDistinctAscList :: String -> CharSet Source

## IntMaps

fromCharSet :: CharSet -> (Bool, IntSet) Source

toCharSet :: IntSet -> CharSet Source

## Array

toArray :: CharSet -> UArray Char Bool Source