hwsl2-bytevector-0.1.0.0: A hashed byte-vector based on algebraic hashes and finger trees

Safe HaskellNone
LanguageHaskell2010

Data.Hash.SL2.ByteVector

Contents

Synopsis

Documentation

Construction

singleton :: Chunk -> ByteVector Source

O(1) Creates a vector from a single chunk.

fromList :: [Chunk] -> ByteVector Source

O(n) Creates a vector from a list of chunks.

Composition

empty :: ByteVector Source

O(1) The empty vector. Alias for mempty.

append :: ByteVector -> ByteVector -> ByteVector Source

O(n) Concatenates two vectors together. Alias for mappend.

cons :: Chunk -> ByteVector -> ByteVector Source

O(1) Adds a chunk to the left end of the vector.

snoc :: ByteVector -> Chunk -> ByteVector Source

O(1) Adds a chunk to the right end of the vector.

Introspection

null :: ByteVector -> Bool Source

O(1) Is this the empty vector?

hash :: ByteVector -> Hash Source

O(1) Returns the hash of the vector.

length :: ByteVector -> Integer Source

O(1) Returns the number of bytes in the vector.

Deconstruction

data ViewL Source

Constructors

EmptyL 
MostL Chunk ByteVector 

Instances

viewl :: ByteVector -> ViewL Source

O(1) Creates a view of the left end of the vector.

viewl1 :: ByteVector -> ViewL Source

O(1) Creates a view of the left end of the vector. The single chunk is guaranteed to never be empty.

data ViewR Source

Constructors

EmptyR 
MostR ByteVector Chunk 

Instances

viewr :: ByteVector -> ViewR Source

O(1) Creates a view of the right end of the vector.

viewr1 :: ByteVector -> ViewR Source

O(1) Creates a view of the right end of the vector. The single chunk is guaranteed to never be empty.

splitBefore :: Integer -> ByteVector -> (ByteVector, ByteVector) Source

O(log(min(i,n-i))) Splits the vector at the chunk where the accumulated length equals the provided integer i. The resulting left side has a length smaller i.

splitAt :: Integer -> ByteVector -> (ByteVector, ByteVector) Source

O(log(min(i,n-i))) Splits the vector at the byte where the accumulated length equals the provided integer i. The resulting left side has a length of min(i,n).

This is potentially less efficient than splitBefore because it has to re-hash parts of the vector.

Transformation

reverse :: ByteVector -> ByteVector Source

O(n) Reverses the vector.

map :: (Chunk -> Chunk) -> ByteVector -> ByteVector Source

O(n) Applies a function to every chunk in the vector.

Reduction

foldl :: (a -> Chunk -> a) -> a -> ByteVector -> a Source

O(n) Folds the vector from left to right.

foldr :: (Chunk -> a -> a) -> a -> ByteVector -> a Source

O(n) Folds the vector from right to left.

foldl' :: (a -> Chunk -> a) -> a -> ByteVector -> a Source

O(n) Folds the vector from left to right, with strict application.

foldr' :: (Chunk -> a -> a) -> a -> ByteVector -> a Source

O(n) Folds the vector from right to left, with strict application.