replaceAll
Replace every element by applying the given operator and update weights accordingly.
Implementation notes:
Computes new element array and weights first.
Validates that all new weights are within bounds and that the resulting weights array is non-decreasing. If validation fails, an IllegalStateException is thrown and no mutation occurs.
If validation passes, internal arrays are overwritten in bulk.
Parameters
operator
mapping function from old element to new element
Throws
if any replacement yields an out-of-bounds weight or the resulting weights are not non-decreasing