Sqrt (or Square Root) Decomposition is a technique used for query an array and perform updates Inside this package is described its most simple data structure, you can find more at: https://cp-algorithms.com/data_structures/sqrt_decomposition.html Formally, You can use SqrtDecomposition only if: G
| 19 | // - (Only if you want use $update$ function) |
| 20 | // $\forall n\in \N > 0, E_1,..., E_n\in E \\ query(E_1,...,E_{new},..., E_n)=updateQ(query(E_1,...,E_{old},...,E_n), indexof(E_{old}), E_{new})$ |
| 21 | type SqrtDecomposition[E any, Q any] struct { |
| 22 | querySingleElement func(element E) Q |
| 23 | unionQ func(q1 Q, q2 Q) Q |
| 24 | updateQ func(oldQ Q, oldE E, newE E) (newQ Q) |
| 25 | |
| 26 | elements []E |
| 27 | blocks []Q |
| 28 | blockSize uint64 |
| 29 | } |
| 30 | |
| 31 | // Create a new SqrtDecomposition instance with the parameters as specified by SqrtDecomposition comment |
| 32 | // Assumptions: |
nothing calls this directly
no outgoing calls
no test coverage detected