Loading...

Streamly.Internal.Data.RingArray.Generic

Documentation

data RingArray a Source #

Constructors

RingArray 

Fields

type Ring = RingArray Source #

Deprecated: Please use RingArray instead.

Generation

emptyOf :: MonadIO m => Int -> m (RingArray a) Source #

createOf :: MonadIO m => Int -> Fold m a (RingArray a) Source #

Note that it is not safe to return a reference to the mutable RingArray using a scan as the RingArray is continuously getting mutated. You could however copy out the RingArray.

Modification

seek :: MonadIO m => Int -> RingArray a -> m (RingArray a) Source #

Move the ring head clockwise (+ve adj) or counter clockwise (-ve adj) by the given amount.

Conversion

toMutArray :: MonadIO m => Int -> Int -> RingArray a -> m (MutArray a) Source #

toMutArray rignHeadAdjustment lengthToRead ring. Convert the ring into a boxed mutable array. Note that the returned MutArray shares the same underlying memory as the RingArray, the user of this API needs to ensure that the ring is not mutated during and after the conversion.

copyToMutArray :: MonadIO m => Int -> Int -> RingArray a -> m (MutArray a) Source #

Copy out the mutable ring to a mutable Array.

toStreamWith :: Int -> RingArray a -> Stream m a Source #

Seek by n and then read the entire ring. Use take on the stream to restrict the reads.