Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 internal abstract bool MergeWith(AbstractStruct right);
Ejemplo n.º 4
0
 internal bool Adds(AbstractStruct str)
 {
     return(!Transaction.BeforeState.TryGetValue(str.Id.Client, out int clock) || str.Id.Clock >= clock);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Check if a struct is added by this event.
 /// </summary>
 internal bool Deletes(AbstractStruct str)
 {
     return(Transaction.DeleteSet.IsDeleted(str.Id));
 }
Ejemplo n.º 6
0
Archivo: GC.cs Proyecto: alex521/ycs
 internal override bool MergeWith(AbstractStruct right)
 {
     Debug.Assert(right is GC);
     Length += right.Length;
     return(true);
 }