Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RingBuffer a
- new :: PrimUnlifted a => Int -> IO (RingBuffer a)
- clear :: PrimUnlifted a => RingBuffer a -> IO ()
- append :: PrimUnlifted a => a -> RingBuffer a -> IO ()
- capacity :: PrimUnlifted a => RingBuffer a -> IO Int
- filledLength :: PrimUnlifted a => RingBuffer a -> IO Int
- latest :: PrimUnlifted a => RingBuffer a -> Int -> IO (Maybe a)
- foldMap :: (PrimUnlifted a, Monoid b) => RingBuffer a -> (a -> IO b) -> IO b
Documentation
data RingBuffer a Source #
:: PrimUnlifted a | |
=> Int | capacity of buffer |
-> IO (RingBuffer a) |
Return a new ring buffer of the specified size.
:: PrimUnlifted a | |
=> RingBuffer a | buffer to clear |
-> IO () |
Reset the buffer to its empty state.
append :: PrimUnlifted a => a -> RingBuffer a -> IO () Source #
Add an item to the end of the buffer.
capacity :: PrimUnlifted a => RingBuffer a -> IO Int Source #
Get the maximum number of items the ring can contain
filledLength :: PrimUnlifted a => RingBuffer a -> IO Int Source #
Get the current filled length of the ring
latest :: PrimUnlifted a => RingBuffer a -> Int -> IO (Maybe a) Source #
Retrieve the \(n\)th most-recently added item of the ring
foldMap :: (PrimUnlifted a, Monoid b) => RingBuffer a -> (a -> IO b) -> IO b Source #
Execute the given action with the items of the ring, accumulating its results.