コード例 #1
0
ファイル: GapSeq.cs プロジェクト: heiseshuixian/swimcube
 private void TryExpandSize(int key)
 {
     if (key >= data.Capacity)
     {
         data.Capacity = GMath.Max(data.Capacity * 2, key + 1);
     }
     for (int i = 0; i < key - Count + 1; i++)
     {
         data.Add(null);
     }
 }
コード例 #2
0
ファイル: NumberTree.cs プロジェクト: heiseshuixian/swimcube
        public float Sum(int range)
        {
            float sum     = 0;
            int   treeInd = range + 1;

            while (treeInd > 0)
            {
                sum     += tree[treeInd];
                treeInd -= GMath.LowBit(treeInd);
            }
            return(sum);
        }
コード例 #3
0
ファイル: GapSeq.cs プロジェクト: heiseshuixian/swimcube
        public virtual bool RemoveByInd(int key)
        {
            if (IsFree(key))
            {
                return(false);
            }
            T old = data[key];

            data[key] = null;
            RemoveUsedKey(key);
            _freeRow = GMath.Min(key, _freeRow);
            if (OnDel != null)
            {
                OnDel(key, old);
            }
            return(true);
        }
コード例 #4
0
ファイル: NumberTree.cs プロジェクト: heiseshuixian/swimcube
        public void Set(int index, float num)
        {
            float delta = num;

            if (index >= Count)
            {
                throw new Exception("[NumberTree Set] argument out of range");
            }
            else
            {
                delta = num - values[index];
            }

            int treeInd = index + 1;

            while (treeInd < TreeCount)
            {
                tree[treeInd] += num;
                treeInd       += GMath.LowBit(treeInd);
            }
        }