mafoc-0.0.0.1
Safe HaskellSafe-Inferred
LanguageHaskell2010

Mafoc.RingBuffer

Synopsis

Documentation

data RingBuffer a #

peek :: RingBuffer a -> IO (Maybe a) #

Add elements

push :: a -> RingBuffer a -> IO (RingBuffer a, Maybe a) #

Push a to buffer, possibly returning carry and the new ringbuffer.

push_ :: a -> RingBuffer a -> IO (RingBuffer a) #

pushMany :: [a] -> RingBuffer a -> IO (RingBuffer a, [a]) #

Push many as to ringBuffer, returning overflow.

Remove oldest elements

pop :: RingBuffer a -> IO (RingBuffer a, Maybe a) #

Pop oldest item.

flush :: RingBuffer a -> IO (RingBuffer a, [a]) #

flushN :: Natural -> RingBuffer a -> IO (RingBuffer a, [a]) #

Pop n oldest items, or less if buffer fill is smaller.

flushWhile :: (a -> Bool) -> RingBuffer a -> IO (RingBuffer a, [a]) #

flushWhile_ :: (a -> Bool) -> RingBuffer a -> IO (RingBuffer a) #

Remove newest elements

unpushWhile :: (a -> Bool) -> RingBuffer a -> IO (RingBuffer a, [a]) #

Unpush newest items from buffer while predicate matches.

unpushWhile_ :: (a -> Bool) -> RingBuffer a -> IO (RingBuffer a) #