Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.Buffer taken from cojna/iota (thanks!) It's a fixed-sized mutable vector with push/pop API.
Synopsis
- data Buffer s a = Buffer {
- bufferVars :: !(MVector s Int)
- initialBufferPos :: !Int
- internalBuffer :: !(MVector s a)
- internalBufferSize :: !Int
- _bufferFrontPos :: Int
- _bufferBackPos :: Int
- newBuffer :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a)
- newRevBuffer :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a)
- buildBuffer :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Buffer (PrimState m) a)
- generateBuffer :: (Unbox a, PrimMonad m) => Int -> (Int -> a) -> m (Buffer (PrimState m) a)
- type Deque s a = Buffer s a
- newBufferAsDeque :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a)
- createBuffer :: Unbox a => (forall s. ST s (Buffer s a)) -> Vector a
- lengthBuffer :: PrimMonad m => Buffer (PrimState m) a -> m Int
- nullBuffer :: PrimMonad m => Buffer (PrimState m) a -> m Bool
- clearBuffer :: PrimMonad m => Buffer (PrimState m) a -> m ()
- freezeBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Vector a)
- unsafeFreezeBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Vector a)
- freezeInternalBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Vector a)
- unsafeFreezeInternalBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Vector a)
- popFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Maybe a)
- popFront_ :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m ()
- popFrontN :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe (Vector a))
- popBackN :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe (Vector a))
- popFrontN_ :: PrimMonad m => Buffer (PrimState m) a -> Int -> m (Maybe ())
- popBackN_ :: PrimMonad m => Buffer (PrimState m) a -> Int -> m (Maybe ())
- popBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Maybe a)
- popBack_ :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m ()
- pushFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> a -> m ()
- pushBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> a -> m ()
- pushFronts :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Vector a -> m ()
- pushBacks :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Vector a -> m ()
- readMaybeFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe a)
- readMaybeBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe a)
- readFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m a
- readBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m a
- _checkIndexBuffer :: (HasCallStack, PrimMonad m) => Buffer (PrimState m) a -> Int -> m ()
- writeFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m ()
- writeBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m ()
- unsafeWriteFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m ()
- unsafeWriteBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m ()
- swapFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m ()
- swapBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m ()
- unsafeSwapFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m ()
- unsafeSwapBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m ()
- modifyFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m ()
- modifyBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m ()
- unsafeModifyFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m ()
- unsafeModifyBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m ()
- modifyMFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m ()
- modifyMBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m ()
- unsafeModifyMFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m ()
- unsafeModifyMBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m ()
- exchangeFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a
- exchangeBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a
- unsafeExchangeFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a
- unsafeExchangeBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a
- cloneBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Buffer (PrimState m) a)
Documentation
A fixed-sized mutable vector with push/pop API.
Buffer | |
|
_bufferFrontPos :: Int #
_bufferBackPos :: Int #
newBuffer :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a) #
\(O(N)\) Creates a buffer of length n
with initial value at zero
. This is mostlly for
queues.
newRevBuffer :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a) #
\(O(N)\) Creates a buffer of length n
with initial value at n - 1
. This is mostly for
stacks.
buildBuffer :: (Unbox a, PrimMonad m) => MVector (PrimState m) a -> m (Buffer (PrimState m) a) #
\(O(N)\) Wraps a mutable vector with push/pop API.
generateBuffer :: (Unbox a, PrimMonad m) => Int -> (Int -> a) -> m (Buffer (PrimState m) a) #
\(O(N)\) Creates a mutable vector with push/pop API.
newBufferAsDeque :: (Unbox a, PrimMonad m) => Int -> m (Buffer (PrimState m) a) #
\(O(N)\) Creates a buffer of length 2 * n
with initial value at n
.
createBuffer :: Unbox a => (forall s. ST s (Buffer s a)) -> Vector a #
\(O(N)\) Freezes a buffer after creation.
clearBuffer :: PrimMonad m => Buffer (PrimState m) a -> m () #
\(O(1)\)
unsafeFreezeInternalBuffer :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> m (Vector a) #
\(O(1)\)
popFrontN :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe (Vector a)) #
\(O(L)\) The popped vector is from left to the right order.
popBackN :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> m (Maybe (Vector a)) #
\(O(L)\) The popped vector is from left to the right order.
_checkIndexBuffer :: (HasCallStack, PrimMonad m) => Buffer (PrimState m) a -> Int -> m () #
writeFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m () #
\(O(1)\)
writeBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m () #
\(O(1)\)
swapFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m () #
\(O(1)\)
swapBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> Int -> m () #
\(O(1)\)
modifyFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m () #
\(O(1)\)
modifyBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m () #
\(O(1)\)
unsafeModifyFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m () #
\(O(1)\)
unsafeModifyBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> a) -> Int -> m () #
\(O(1)\)
modifyMFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m () #
\(O(1)\)
modifyMBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m () #
\(O(1)\)
unsafeModifyMFront :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m () #
\(O(1)\)
unsafeModifyMBack :: (Unbox a, PrimMonad m) => Buffer (PrimState m) a -> (a -> m a) -> Int -> m () #
\(O(1)\)
exchangeFront :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a #
\(O(1)\)
exchangeBack :: (HasCallStack, Unbox a, PrimMonad m) => Buffer (PrimState m) a -> Int -> a -> m a #
\(O(1)\)