public double ValueForIndex(int index, bool approximate = true) { if (approximate || this.indicesWithValue[index]) { return(IndexStorage.LongToDouble(this[index], IndexStorage.PrecisionMultiplier)); } return(0.0); }
public double OffsetFromIndex(int endIndex) { if (this.aggregateInfoUpdateInProgress) { Debugger.Break(); } var index = endIndex; // Debug.Assert is not enough! // in some cases like continuous adding of a new item (ShowInsertRow = true) // without these two checks exception is thrown if (index < 0) { return(this[0]); } if (index >= this.storage.Length) { return(this[this.storage.Length - 1]); } long result = this[index]; if ((index % 2) == 1) { result += this[index - 1]; } index = (index + this.size) >> 1; while (index != 1) { bool comeFromRight = index % 2 == 1; if (comeFromRight) { result += this.aggregateInfo[index - 1]; } index >>= 1; } return(IndexStorage.LongToDouble(result, IndexStorage.PrecisionMultiplier)); }