示例#1
0
        public void AddStruct(AbstractStruct str)
        {
            if (!Clients.TryGetValue(str.Id.Client, out var structs))
            {
                structs = new List <AbstractStruct>();
                Clients[str.Id.Client] = structs;
            }
            else
            {
                var lastStruct = structs[structs.Count - 1];
                if (lastStruct.Id.Clock + lastStruct.Length != str.Id.Clock)
                {
                    throw new Exception("Unexpected");
                }
            }

            structs.Add(str);
        }
示例#2
0
        public (AbstractStruct item, int diff) FollowRedone(ID id)
        {
            ID?            nextId = id;
            int            diff   = 0;
            AbstractStruct item;

            do
            {
                if (diff > 0)
                {
                    nextId = new ID(nextId.Value.Client, nextId.Value.Clock + diff);
                }

                item   = Find(nextId.Value);
                diff   = nextId.Value.Clock - item.Id.Clock;
                nextId = (item as Item)?.Redone;
            } while (nextId != null && item is Item);

            return(item, diff);
        }
示例#3
0
 internal abstract bool MergeWith(AbstractStruct right);
示例#4
0
文件: YEvent.cs 项目: alex521/ycs
 internal bool Adds(AbstractStruct str)
 {
     return(!Transaction.BeforeState.TryGetValue(str.Id.Client, out int clock) || str.Id.Clock >= clock);
 }
示例#5
0
文件: YEvent.cs 项目: alex521/ycs
 /// <summary>
 /// Check if a struct is added by this event.
 /// </summary>
 internal bool Deletes(AbstractStruct str)
 {
     return(Transaction.DeleteSet.IsDeleted(str.Id));
 }
示例#6
0
文件: GC.cs 项目: alex521/ycs
 internal override bool MergeWith(AbstractStruct right)
 {
     Debug.Assert(right is GC);
     Length += right.Length;
     return(true);
 }