rrb-vector-0.2.2.0: Efficient RRB-Vectors
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.RRBVector.Internal.Buffer

Description

This is an internal module.

A Buffer is an array with a fixed capacity, used to build up Arrays. It is used in the implementation of fromList and ><.

Synopsis

Documentation

data Buffer s a Source #

A mutable array buffer with a fixed capacity.

new :: Int -> ST s (Buffer s a) Source #

\(O(n)\). Create a new empty buffer with the given capacity.

push :: Buffer s a -> a -> ST s () Source #

\(O(1)\). Push a new element onto the buffer. The size of the buffer must not exceed the capacity, but this is not checked.

get :: Buffer s a -> ST s (Array a) Source #

\(O(n)\). Freeze the content of the buffer and return it. This resets the buffer so that it is empty.

size :: Buffer s a -> ST s Int Source #

\(O(1)\). Return the current size of the buffer.