Skip to main content

solve_blocked

Function solve_blocked 

Source
pub fn solve_blocked<State, FAdd, FRemove, FVisit>(
    n: usize,
    queries: &[Query],
    state: &mut State,
    add: FAdd,
    remove: FRemove,
    visit: FVisit,
)
where State: ?Sized, FAdd: FnMut(&mut State, usize), FRemove: FnMut(&mut State, usize), FVisit: FnMut(&mut State, usize),
Expand description

Run a generic Mo’s algorithm over n elements answering queries.

All moving window bookkeeping is done in this function; the caller supplies a single state value passed to each callback. Interior mutability (e.g. RefCell) lets one state object serve all three callbacks if you need shared mutable bookkeeping.