private void _Insert(KeyType Key, ulong UpdateCode)
        {
            var Update = new UpdateAble <KeyType>()
            {
                Key = Key, UpdateCode = UpdateCode
            };

            ArrayExtentions.ArrayExtentions.BinaryInsert(
                ref UpdateCodes, Update, UpdateAble <KeyType> .CompareCode);
            ArrayExtentions.ArrayExtentions.BinaryInsert(
                ref UpdateKeys, Update, UpdateAble <KeyType> .CompareKey);
        }
        private void _Changed(KeyType Old, KeyType New, ulong UpdateCode, int OldPlace_key)
        {
            var OldUpdate = UpdateKeys[OldPlace_key];
            var NewUpdate = new UpdateAble <KeyType>()
            {
                Key = New, UpdateCode = UpdateCode
            };

            ArrayExtentions.ArrayExtentions.BinaryUpdate(
                UpdateKeys, OldUpdate, NewUpdate, UpdateAble <KeyType> .CompareKey);
            ArrayExtentions.ArrayExtentions.BinaryUpdate(
                UpdateCodes, OldUpdate, NewUpdate, UpdateAble <KeyType> .CompareCode);
        }
        public void Insert(KeyType Key, ulong UpdateCode)
        {
            var Update = new UpdateAble <KeyType>()
            {
                Key = Key, UpdateCode = UpdateCode
            };
            var Place = System.Array.BinarySearch(UpdateKeys, Update, UpdateAble <KeyType> .CompareKey);

            if (Place >= 0)
            {
                _Changed(Key, Key, UpdateCode, Place);
                return;
            }
            _Insert(Key, UpdateCode);
        }
예제 #4
0
            public void DeleteExtraItems(ulong UpdateCode)
            {
                UpdateAble <KeyType> MyUpCode = null;

                while (Table.UpdateAble.UpdateCodes.Length > StartPos)
                {
                    MyUpCode = Table.UpdateAble.UpdateCodes[StartPos];
                    if (MyUpCode.UpdateCode < UpdateCode)
                    {
                        Table.UpdateAble.DeleteDontUpdate(MyUpCode.Key);
                        ShouldDelete.Insert(MyUpCode.Key);
                    }
                    else
                    {
                        return;
                    }
                }
            }
 public UpdateAbles(int Len = 0)
 {
     UpdateCodes = new UpdateAble <KeyType> [Len];
     UpdateKeys  = new UpdateAble <KeyType> [Len];
 }
 public int Compare(UpdateAble <KeyType> x, UpdateAble <KeyType> y)
 {
     return(x.UpdateCode.CompareTo(y.UpdateCode));
 }
 public int Compare(UpdateAble <KeyType> x, UpdateAble <KeyType> y)
 {
     return(x.Key.CompareTo(y.Key));
 }
예제 #8
0
            private async Task UpdateNextItems()
            {
                var Len = await Client.GetData <int>();

                var ServerUpCodes = new ulong[Len];

                ulong[] ServerUpCodes_Parent = null;
                if (IsPartOfTable)
                {
                    ServerUpCodes_Parent = new ulong[Len];
                }
                for (int i = 0; i < Len; i++)
                {
                    var UpCode = await Client.GetData <ulong>();

                    if (IsPartOfTable)
                    {
                        var ParentUpCode = await Client.GetData <ulong>();

                        if (ParentTable.UpdateAble.IsExist(ParentUpCode))
                        {
                            var ParentUpDate = ParentTable.UpdateAble[ParentUpCode];
                            if (PartTable.IsExist(ParentUpDate.Key) == false)
                            {
                                PartTable.Accept(ParentUpDate.Key);
                            }
                            Added(ParentUpDate.Key, UpCode);
                            await Client.SendData(false);

                            StartPos++;
                            Len--;
                            i--;
                        }
                        else
                        {
                            await Client.SendData(true);

                            ServerUpCodes[i]        = UpCode;
                            ServerUpCodes_Parent[i] = ParentUpCode;
                        }
                    }
                    else
                    {
                        await Client.SendData(true);

                        ServerUpCodes[i] = UpCode;
                    }
                }
                for (int i = 0; i < Len; i++)
                {
                    var Value = await Client.GetData <ValueType>();

                    var Key    = Table.GetKey(Value);
                    var Update = new UpdateAble <KeyType>()
                    {
                        Key = Key, UpdateCode = ServerUpCodes[i]
                    };
                    Table.UpdateOrInsert(Key, (c) =>
                    {
                        Table.MoveRelations(c, Value);
                        return(Value);
                    });
                    if (IsPartOfTable)
                    {
                        Added(Key, ServerUpCodes[i], ServerUpCodes_Parent[i]);
                    }
                    else
                    {
                        Added(Key, ServerUpCodes[i]);
                    }
                    StartPos++;
                }
            }