text-containers-0.1.0.0: Memory-efficient string-indexed container types.

Copyright© 2017 Herbert Valerio Riedel
LicenseGPLv3
Safe HaskellTrustworthy
LanguageHaskell2010

Data.TextArray.Unboxed

Contents

Description

This module provides the TextArray container for storing arrays of text strings.

This module is intended to be imported qualified, e.g.

import           Data.TextArray.Unboxed (TextArr)
import qualified Data.TextArray.Unboxed as TextArr

Synopsis

Documentation

data TextArray Source #

An array of unboxed ShortText strings

The memory footprint of this data-structure is a single heap object (an unlifted ByteArray#) with the size expressed in words

\[ 3 + n + \left\lceil \frac{1}{w} \sum_{i=0}^{n-1} len(s_i) \right\rceil \]

where the word-size \(w\) is either \(w = 4\) or \(w = 8\) bytes; and where \(len(s_i)\) denotes the UTF-8 size in bytes of the \(i\)-th text string.

NOTE: Depending on whether you UNPACK the TextArray wrapper, you need at least one additional word for the pointer to the internal ByteArray# heap object.

Instances

IsList TextArray Source # 

Associated Types

type Item TextArray :: * #

Eq TextArray Source # 
Ord TextArray Source # 
Read TextArray Source # 
Show TextArray Source # 
Semigroup TextArray Source #

\(\mathcal{O}(n+m)\). Concatenate two TextArrays.

Monoid TextArray Source # 
NFData TextArray Source # 

Methods

rnf :: TextArray -> () #

Hashable TextArray Source # 
type Item TextArray Source # 
type Item TextArray = ShortText

Querying & lookup

null :: TextArray -> Bool Source #

\(\mathcal{O}(1)\). Test whether TestArray is empty.

length :: TextArray -> Int Source #

\(\mathcal{O}(1)\). Return number of strings contained in TestArray.

elem :: ShortText -> TextArray -> Bool Source #

\(\mathcal{O}(n)\). Test whether TestArray contains a specific string.

elemIndices :: ShortText -> TextArray -> [Int] Source #

\(\mathcal{O}(n)\). Find occurences of given string in TextArray and report list of indices (in ascending order).

(!?) :: TextArray -> Int -> Maybe ShortText Source #

\(\mathcal{O}(1)\). Array indexing (0-based).

Construction

empty :: TextArray Source #

\(\mathcal{O}(1)\). An empty TextArray

singleton :: ShortText -> TextArray Source #

\(\mathcal{O}(1)\). Construct TextArray with single element

fromList :: [ShortText] -> TextArray Source #

\(\mathcal{O}(n)\). Construct TextArray from list of strings.

Deconstruction

toList :: TextArray -> [ShortText] Source #

\(\mathcal{O}(n)\). Deconstruct TextArray into list of strings.