Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Mo's Algotrithm
Synopsis
- moAlgorithm :: (Unbox a, PrimMonad m) => Int -> Int -> (a -> Int -> m a) -> (a -> Int -> m a) -> a -> Vector MoQuery -> m (Vector a)
- moBlockSize :: Int -> Int -> Int
- data MoState a = MoState !Int !Int !a
- data MoQuery = MoQuery !Int !Int !Int
- moSort :: Int -> Vector MoQuery -> Vector MoQuery
- moEncode :: Int -> MoQuery -> Word64
- moDecodeQueryIndex :: Word64 -> Int
- encodeMoQuery :: MoQuery -> Word64
- decodeMoQuery :: Word64 -> MoQuery
Documentation
:: (Unbox a, PrimMonad m) | |
=> Int | index size (N) |
-> Int | query size (Q) |
-> (a -> Int -> m a) | add |
-> (a -> Int -> m a) | delete |
-> a | initial value |
-> Vector MoQuery | query [l, r) |
-> m (Vector a) |
O(N * sqrt Q)
query for [l,r)
Instances
moDecodeQueryIndex :: Word64 -> Int Source #
encodeMoQuery :: MoQuery -> Word64 Source #
decodeMoQuery :: Word64 -> MoQuery Source #