public ISparseArrayNode <T> SetValue(ulong position, T value)
        {
            if (this.from <= position && position <= this.to)
            {
                ushort nslot = this.GetSlotPosition(position);
                if (this.subnodes[nslot] == null)
                {
                    if (this.level == 1)
                    {
                        this.subnodes[nslot] = new SparseArrayLeafNode <T>(position, this.size);
                    }
                    else
                    {
                        this.subnodes[nslot] = new SparseArrayNode <T>(position, (ushort)(this.level - 1), this.size);
                    }
                }

                this.subnodes[nslot].SetValue(position, value);
                return(this);
            }

            SparseArrayNode <T> parent = new SparseArrayNode <T>(this.from, (ushort)(this.level + 1), this.size);

            parent.SetSlot(this.from, this);

            return(parent.SetValue(position, value));
        }
Exemple #2
0
        public ISparseArrayNode <T> SetValue(ulong position, T value)
        {
            if (this.from <= position && position <= this.from + (ushort)(this.size - 1))
            {
                this.values[position - this.from] = value;
                return(this);
            }

            SparseArrayNode <T> parent = new SparseArrayNode <T>(this.from, 1, this.size);

            parent.SetSlot(this.from, this);

            return(parent.SetValue(position, value));
        }