Esempio n. 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);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Removes the element at the given index. Worst complexity is
        /// (N-InsertIndex) + Log(N)*NonDefaultsInRange(N-InsertIndex).
        /// </summary>
        /// <param name="index">The index at which to remove the item.</param>
        public void RemoveAt(int index)
        {
            IndexStorage.CheckIndex(index, this.size);

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

            if (this.count > 0)
            {
                this[this.count - 1] = 0;
                this.count--;
            }

            this.RefreshAggregateInfo();
        }
Esempio n. 3
0
        public void RemoveRange(int index, int removeItemsCount)
        {
            IndexStorage.CheckIndex(index, this.size);
            IndexStorage.CheckIndex(index + removeItemsCount, this.size);

            Array.Copy(this.storage, index + removeItemsCount, this.storage, index, this.storage.Length - index - removeItemsCount);
            Array.Copy(this.indicesWithValue, index + removeItemsCount, this.indicesWithValue, index, this.indicesWithValue.Length - index - removeItemsCount);

            for (int i = this.storage.Length - 1; i >= this.storage.Length - removeItemsCount; i--)
            {
                this.storage[i]          = 0;
                this.indicesWithValue[i] = false;
            }

            this.count -= removeItemsCount;

            this.RefreshAggregateInfo();
        }