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