Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
AtCoder.Extra.Seq.Raw
Description
Base module for implementing dynamic sequences. It internaly uses a splay tree and user has to track the root node change.
Since: 1.2.0.0
Synopsis
- data Seq s f a = Seq {}
- newST :: (Monoid f, Unbox f, Monoid a, Unbox a) => Int -> ST s (Seq s f a)
- resetST :: Seq s f a -> ST s ()
- newNodeST :: (Monoid f, Unbox f, Unbox a) => Seq s f a -> a -> ST s Index
- newSeqST :: (Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Vector a -> ST s Index
- freeNodeST :: Seq s v a -> Index -> ST s ()
- freeSubtreeST :: Unbox a => Seq s f a -> Index -> ST s ()
- mergeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> ST s Index
- merge3ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> Index -> ST s Index
- merge4ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> Index -> Index -> ST s Index
- splitST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (Index, Index)
- split3ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (Index, Index, Index)
- split4ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> Int -> ST s (Index, Index, Index, Index)
- splitLrST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> ST s (Index, Index, Index)
- sliceST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s Index
- readST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (a, Index)
- readMaybeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (Maybe (a, Index))
- writeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s Index
- modifyST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (a -> a) -> Int -> ST s Index
- exchangeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s (a, Index)
- prodST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (a, Index)
- prodMaybeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (Maybe (a, Index))
- prodAllST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> ST s a
- applyInST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> f -> ST s Index
- applyToRootST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> f -> ST s ()
- reverseST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s Index
- insertST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s Index
- deleteST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (a, Index)
- deleteST_ :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index
- detachST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index
- rotateST :: HasCallStack => Seq s v a -> Index -> ST s ()
- splayST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Bool -> ST s ()
- splayKthST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index
- ilowerBoundST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Int, Index)
- ilowerBoundM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Int, Index)
- ilowerBoundProdST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Int, Index)
- ilowerBoundProdM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Int, Index)
- isplitMaxRightST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Index, Index)
- isplitMaxRightM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Index, Index)
- isplitMaxRightProdST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Index, Index)
- isplitMaxRightProdM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Index, Index)
- imaxRightST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Int, Index, Index)
- imaxRightM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Int, Index, Index)
- imaxRightProdST :: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (Int -> a -> Bool) -> ST s (Int, Index, Index)
- imaxRightProdM :: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq (PrimState m) f a -> Index -> (Int -> a -> m Bool) -> m (Int, Index, Index)
- freezeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> ST s (Vector a)
Seq
Storages of dynamic sequences of monoid values with monoid actions on them through the SegAct
instance.
Since: 1.2.0.0
Constructors
Seq | |
Fields
|
Constructors
newST :: (Monoid f, Unbox f, Monoid a, Unbox a) => Int -> ST s (Seq s f a) Source #
\(O(n)\) Creates a new Seq
of length \(n\).
Since: 1.2.0.0
newNodeST :: (Monoid f, Unbox f, Unbox a) => Seq s f a -> a -> ST s Index Source #
\(O(1)\) Allocates a new sequence of length \(1\).
Since: 1.2.0.0
newSeqST :: (Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Vector a -> ST s Index Source #
\(O(n)\) Allocates a new sequence.
Since: 1.2.0.0
freeSubtreeST :: Unbox a => Seq s f a -> Index -> ST s () Source #
\(O(n)\) Frees a subtree.
Since: 1.2.0.0
Merge/split
mergeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> ST s Index Source #
Amortized \(O(\log n)\). Merges two sequences \(l, r\) into one in the given order, ignoring empty sequences.
Constraints
- The vertices must be either null or a root.
Since: 1.2.0.0
merge3ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> Index -> ST s Index Source #
Amortized \(O(\log n)\). Merges three sequences \(l, m, r\) into one in the given order, ignoring empty sequences.
Constraints
- The vertices must be either null or a root.
Since: 1.2.0.0
merge4ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Index -> Index -> Index -> ST s Index Source #
Amortized \(O(\log n)\). Merges four sequences \(l, b, c, d, m, r\) into one in the given order, ignoring empty sequences.
Constraints
- The vertices must be either null or a root.
Since: 1.2.0.0
splitST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (Index, Index) Source #
Amortized \(O(\log n)\). Splits a sequences into two: \([0, k), [k, n)\).
Constraints
- The node must be null or a root.
- \(0 \le k \le n\).
Since: 1.2.0.0
split3ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (Index, Index, Index) Source #
Amortized \(O(\log n)\). Splits a sequences into three: \([0, l), [l, r), [r, n)\).
Constraints
- The node must be null or a root.
- \(0 \le l \le r \le n\).
Since: 1.2.0.0
split4ST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> Int -> ST s (Index, Index, Index, Index) Source #
Amortized \(O(\log n)\). Splits a sequences into four: \([0, i), [i, j), [j, k), [k, n)\).
Constraints
- The node must be null or a root.
- \(0 \le i \le j \le k \le n\).
Since: 1.2.0.0
splitLrST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> ST s (Index, Index, Index) Source #
Amortized \(O(\log n)\). Splits a sequence into three: \([0, \mathrm{root}), \mathrm{root}, [\mathrm{root} + 1, n)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
sliceST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Captures the root of a subtree of \([l, r)\). Splay the new root after call.
Constraints
- \(0 \le \lt r \le n\). Note that the interval must have positive length.
Since: 1.2.0.0
Read/write
readST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (a, Index) Source #
Amortized \(O(\log n)\). Reads the \(k\)-th node's monoid value.
Constraints
- \(0 \le k \lt n\)
Since: 1.2.0.0
readMaybeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (Maybe (a, Index)) Source #
Amortized \(O(\log n)\). Reads the \(k\)-th node's monoid value.
Constraints
- The root must be empty or a root.
Since: 1.2.0.0
writeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s Index Source #
Amortized \(O(\log n)\). Writes to the \(k\)-th node's monoid value.
Constraints
- The node must be a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
modifyST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> (a -> a) -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Modifies the \(k\)-th node's monoid value.
Constraints
- The node must be a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
exchangeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s (a, Index) Source #
Amortized \(O(\log n)\). Exchanges the \(k\)-th node's monoid value.
Constraints
- The node must be a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
Products
prodST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (a, Index) Source #
Amortized \(O(\log n)\). Returns the monoid product in an interval \([l, r)\).
Constraints
- The node must be a root
- \(0 \le l \le r \le n\)
Since: 1.2.0.0
prodMaybeST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s (Maybe (a, Index)) Source #
Amortized \(O(\log n)\). Returns the monoid product in an interval \([l, r)\). Returns
Nothing
if an invalid interval is given or for an empty sequence.
Since: 1.2.0.0
prodAllST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> ST s a Source #
Amortized \(O(\log n)\). Returns the monoid product of the whole sequence. Returns mempty
for an empty sequence.
Constraint
- The node must be null or a root.
Since: 1.2.0.0
Applications
applyInST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> f -> ST s Index Source #
Amortized \(O(\log n)\). Given an interval \([l, r)\), applies a monoid action \(f\).
Constraints
- \(0 \le l \le r \le n\)
- The root must point to a non-empty sequence.
Since: 1.2.0.0
applyToRootST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> f -> ST s () Source #
\(O(1)\) Applies a monoid action \(f\) to the root of a sequence.
Since: 1.2.0.0
reverseST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Reverses the sequence in \([l, r)\).
Constraints
- The monoid action \(f\) must be commutative.
- The monoid value \(v\) must be commutative.
Since: 1.2.0.0
Insert/delete
insertST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> a -> ST s Index Source #
Amortized \(O(\log n)\). Inserts a new node at \(k\) with initial monoid value \(v\). This functions for an empty index.
Constraints
- The node must be null or a root.
- \(0 \le k \le n\)
Since: 1.2.0.0
deleteST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s (a, Index) Source #
Amortized \(O(\log n)\). Frees the \(k\)-th node and returns the monoid value of it.
Constraints
- The node must be null or a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
deleteST_ :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Frees the \(k\)-th node.
Constraints
- The node must be null or a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
detachST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Detaches the \(k\)-th node and returns the new root of the original sequence.
Constraints
- The node must be null or a root.
- \(0 \le k \lt n\)
Since: 1.2.0.0
Balancing
rotateST :: HasCallStack => Seq s v a -> Index -> ST s () Source #
Amortized \(O(\log n)\). Rotates a child node.
Constraints
- \(0 \le i \lt n\)
Since: 1.2.0.0
splayST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Bool -> ST s () Source #
Amortized \(O(\log n)\). Moves up a node to be a root.
Since: 1.2.0.0
splayKthST :: (HasCallStack, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) => Seq s f a -> Index -> Int -> ST s Index Source #
Amortized \(O(\log n)\). Finds \(k\)-th node and splays it. Returns the new root.
Constraints
- \(0 \le k \lt n\)
Since: 1.2.0.0
Bisection methods
C++-like
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> ST s (Int, Index) | (r, root) |
Amortized \(O(\log n)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> m (Int, Index) | (r, root) |
Amortized \(O(\log n)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_0 \dots v_i)\) that takes the index and the monoid product |
-> ST s (Int, Index) | (r, root) |
Amortized \(O(\log n)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_0 \dots v_i)\) that takes the index and the monoid product |
-> m (Int, Index) | (r, root) |
Amortized \(O(\log n)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Splits
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> ST s (Index, Index) | (left, right) sequences where \(f\) holds for the left |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> m (Index, Index) | (left, right) sequences where \(f\) holds for the left |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_0 \dots v_i)\) that takes the index and the monoid value |
-> ST s (Index, Index) | (left, right) sequences where \(f\) holds for the left |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value | \(r\) |
-> m (Index, Index) | (left, right) sequences where \(f\) holds for the left |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Max right
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> ST s (Int, Index, Index) | (r, left, right) |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v\) where \(f(v)\) holds for every \(v_i (0 \le i \lt k)\). Note that \(f\) works for a single node, not a monoid product.
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_i)\) that takes the index and the monoid value |
-> m (Int, Index, Index) | (r, left, right) |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \(v_i (0 \le i \le k)\). Note that \(f\) works for a single node, not a monoid product.
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq s f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> Bool) | User predicate \(f(i, v_0 \dots v_i)\) that takes the index and the monoid value |
-> ST s (Int, Index, Index) | (ilowerBound, rightmost node, new root) |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0
Arguments
:: (PrimMonad m, SegAct f a, Eq f, Monoid f, Unbox f, Monoid a, Unbox a) | |
=> Seq (PrimState m) f a | Sequence storage |
-> Index | Root node |
-> (Int -> a -> m Bool) | User predicate \(f(i, v_0 \dots v_i)\) that takes the index and the monoid value |
-> m (Int, Index, Index) | (ilowerBound, rightmost node, new root) |
Amortized \(O(\log n)\). Given a monotonious sequence, returns the rightmost node \(v_k\) where \(f(v)\) holds for every \([0, i) (0 \le i \lt k)\).
Constraints
- The node must be a root.
Since: 1.2.0.0