byteset-0.1.1.0: Set of bytes.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.ByteSet

Contents

Description

Inspired in the Data.IntSet API, a similar API where the elements of the set are bytes (values of type Word8).

Synopsis

Types

data ByteSet Source

Set of bytes (Word8). Note that NF and WHNF are equivalent for values of type ByteSet.

Query

null :: ByteSet -> Bool Source

O(1). Is the byteset empty?

size :: ByteSet -> Int Source

O(1). Cardinality of the byteset.

member :: Word8 -> ByteSet -> Bool Source

O(1). Is the value a member of the byteset?

notMember :: Word8 -> ByteSet -> Bool Source

O(1). Is the element not in the set?

Construction

empty :: ByteSet Source

O(1). The empty byteset.

singleton :: Word8 -> ByteSet Source

O(1). A byteset of one element.

insert :: Word8 -> ByteSet -> ByteSet Source

O(1). Add a value to the byteset.

delete :: Word8 -> ByteSet -> ByteSet Source

O(1). Delete a byte in the byteset. Returns the original byteset when the byte was not present.

Combine

union :: ByteSet -> ByteSet -> ByteSet Source

O(1). The union of two bytesets.

unions :: [ByteSet] -> ByteSet Source

The union of a list of bytesets. Just a fold over the list using union.

difference :: ByteSet -> ByteSet -> ByteSet Source

O(1). Difference between two bytesets.

intersection :: ByteSet -> ByteSet -> ByteSet Source

O(1). The intersection of two bytesets.

Filter

filter :: (Word8 -> Bool) -> ByteSet -> ByteSet Source

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

Map

map :: (Word8 -> Word8) -> ByteSet -> ByteSet Source

O(n). Map a function over a byteset.

Folds

foldr :: (Word8 -> a -> a) -> a -> ByteSet -> a Source

O(n). Fold the elements in the byteset using the given right-associative binary operator.

List conversion

elems :: ByteSet -> [Word8] Source

O(n). The elements of a byteset in ascending order.

toList :: ByteSet -> [Word8] Source

O(n). An alias of elems.

fromList :: [Word8] -> ByteSet Source

O(n). Create a byteset from a list of bytes.