Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Hash.SL2.ByteVector
- data ByteVector
- singleton :: Chunk -> ByteVector
- fromList :: [Chunk] -> ByteVector
- empty :: ByteVector
- append :: ByteVector -> ByteVector -> ByteVector
- cons :: Chunk -> ByteVector -> ByteVector
- snoc :: ByteVector -> Chunk -> ByteVector
- null :: ByteVector -> Bool
- hash :: ByteVector -> Hash
- length :: ByteVector -> Integer
- data ViewL
- viewl :: ByteVector -> ViewL
- viewl1 :: ByteVector -> ViewL
- data ViewR
- viewr :: ByteVector -> ViewR
- viewr1 :: ByteVector -> ViewR
- splitBefore :: Integer -> ByteVector -> (ByteVector, ByteVector)
- splitAt :: Integer -> ByteVector -> (ByteVector, ByteVector)
- reverse :: ByteVector -> ByteVector
- map :: (Chunk -> Chunk) -> ByteVector -> ByteVector
- foldl :: (a -> Chunk -> a) -> a -> ByteVector -> a
- foldr :: (Chunk -> a -> a) -> a -> ByteVector -> a
- foldl' :: (a -> Chunk -> a) -> a -> ByteVector -> a
- foldr' :: (Chunk -> a -> a) -> a -> ByteVector -> a
Documentation
data ByteVector Source
Instances
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
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
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.
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.