Copyright | © 2017 Herbert Valerio Riedel |
---|---|
License | GPLv3 |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
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
- data TextArray
- null :: TextArray -> Bool
- length :: TextArray -> Int
- elem :: ShortText -> TextArray -> Bool
- elemIndices :: ShortText -> TextArray -> [Int]
- (!?) :: TextArray -> Int -> Maybe ShortText
- empty :: TextArray
- singleton :: ShortText -> TextArray
- fromList :: [ShortText] -> TextArray
- toList :: TextArray -> [ShortText]
Documentation
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.
IsList TextArray Source # | |
Eq TextArray Source # | |
Ord TextArray Source # | |
Read TextArray Source # | |
Show TextArray Source # | |
Semigroup TextArray Source # | \(\mathcal{O}(n+m)\). Concatenate two |
Monoid TextArray Source # | |
NFData TextArray Source # | |
Hashable TextArray Source # | |
type Item TextArray Source # | |
Querying & lookup
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).
Construction
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.