Exemple #1
0
 private long this[int index]
 {
     get
     {
         IndexStorage.CheckIndex(index, this.size);
         return(this.storage[index]);
     }
     set
     {
         IndexStorage.CheckIndex(index, this.size);
         IndexStorage.CheckValue(value);
         this.Set(index, value);
     }
 }
Exemple #2
0
        public void Add(double value)
        {
            long val = IndexStorage.DoubleToLong(value, IndexStorage.PrecisionMultiplier);

            IndexStorage.CheckValue(val);

            if (this.Count == this.size)
            {
                this.ExtendCapacity(this.size * 2);
                this.RefreshAggregateInfo();
            }

            this.count++;
            this[this.Count - 1] = val;
        }
Exemple #3
0
        internal IndexStorage(int capacity, double defaultVal)
        {
            this.itemDefaultValue = IndexStorage.DoubleToLong(defaultVal, IndexStorage.PrecisionMultiplier);

            IndexStorage.CheckValue(this.itemDefaultValue);

            this.count = capacity;
            this.size  = 8;
            while (this.size <= capacity)
            {
                this.size <<= 1;
            }

            this.indicesWithValue = new bool[this.size];
            this.storage          = new long[this.size];
            this.aggregateInfo    = new long[this.size];

            this.Initialize(null, capacity, this.itemDefaultValue);
        }
Exemple #4
0
        public void Insert(int index, double value)
        {
            long val = IndexStorage.DoubleToLong(value, IndexStorage.PrecisionMultiplier);

            IndexStorage.CheckValue(val);

            if (this.Count + 1 == this.size)
            {
                this.ExtendCapacity(this.size * 2);
            }

            Array.Copy(this.storage, index, this.storage, index + 1, this.size - index - 1);
            Array.Copy(this.indicesWithValue, index, this.indicesWithValue, index + 1, this.size - index - 1);

            this.RefreshAggregateInfo();

            this.count++;
            this[index] = val;
        }
Exemple #5
0
        public void InsertRange(int index, double?value, int insertItemsCount)
        {
            long val = 0;

            if (value.HasValue)
            {
                val = IndexStorage.DoubleToLong(value.Value, IndexStorage.PrecisionMultiplier);

                IndexStorage.CheckValue(val);
            }

            int newSize = this.size;

            while (this.Count + insertItemsCount >= newSize)
            {
                newSize *= 2;
            }

            if (newSize != this.size)
            {
                this.ExtendCapacity(newSize);
            }

            Array.Copy(this.storage, index, this.storage, index + insertItemsCount, this.size - index - insertItemsCount);
            Array.Copy(this.indicesWithValue, index, this.indicesWithValue, index + insertItemsCount, this.size - index - insertItemsCount);

            this.count += insertItemsCount;

            for (int i = 0; i < insertItemsCount; i++)
            {
                if (value.HasValue)
                {
                    this.storage[index + i]          = val;
                    this.indicesWithValue[index + i] = true;
                    this.HasUpdatedValues            = true;
                }
            }

            this.RefreshAggregateInfo();
        }