Exemplo n.º 1
0
        public double ValueForIndex(int index, bool approximate = true)
        {
            if (approximate || this.indicesWithValue[index])
            {
                return(IndexStorage.LongToDouble(this[index], IndexStorage.PrecisionMultiplier));
            }

            return(0.0);
        }
Exemplo n.º 2
0
        public double OffsetFromIndex(int endIndex)
        {
            ////IndexStorage.CheckIndex(endIndex, this.size);

            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.storage[0]);
            }

            if (index >= this.storage.Length)
            {
                return(this.storage[this.storage.Length - 1]);
            }

            long result = this.storage[index];

            if ((index % 2) == 1)
            {
                result += this.storage[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));
        }