private static void Add(T[] data, int p, T w) { for (++p; p < data.Length; p += (int)InternalBit.ExtractLowestSetBit(p)) { data[p] = op.Add(data[p], w); } }
public void Add(int p, TValue x) { Debug.Assert(unchecked ((uint)p < data.Length)); for (p++; p < data.Length; p += InternalBit.ExtractLowestSetBit(p)) { data[p] = op.Add(data[p], x); } }
public void Add(int p, TValue x) { Contract.Assert((uint)p < (uint)Length, reason: $"IndexOutOfRange: 0 <= {nameof(p)} && {nameof(p)} < Length"); for (++p; p < data.Length; p += (int)InternalBit.ExtractLowestSetBit(p)) { data[p] = op.Add(data[p], x); } }
private TValue Sum(int r) { TValue s = default; for (; r > 0; r -= InternalBit.ExtractLowestSetBit(r)) { s = op.Add(s, data[r]); } return(s); }
public void Add(int h, int w, T v) { for (var hh = h + 1; hh < tree.Length; hh += (int)InternalBit.ExtractLowestSetBit(hh)) { for (var ww = w + 1; ww < tree[hh].Length; ww += (int)InternalBit.ExtractLowestSetBit(ww)) { tree[hh][ww] = op.Add(tree[hh][ww], v); } } }