byteset-0.1.1.0: Set of bytes.

Data.ByteSet

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`.

Instances

 Eq ByteSet Ord ByteSet Show ByteSet Generic ByteSet Binary ByteSet type Rep ByteSet

data Word8 :: *

8-bit unsigned integer type

Instances

 Bounded Word8 Enum Word8 Eq Word8 Integral Word8 Num Word8 Ord Word8 Read Word8 Real Word8 Show Word8 Ix Word8 Bits Word8 FiniteBits Word8 Binary Word8

# Query

O(1). Is the byteset empty?

O(1). Cardinality of the byteset.

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

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

# Construction

O(1). The empty byteset.

O(1). A byteset of one element.

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

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

# Combine

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`.

O(1). Difference between two bytesets.

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.