void IDataLoggable.CollectChangeLogs(string parent, IList <DataLog> logs) { for (int i = 0, imax = mRemoved.Count; i < imax; i++) { logs.Add(DataLog.Delete(parent, mRemoved[i])); } for (int i = 0; i < _size; i++) { Node n = _items[i]; if (n.s == 0) { continue; } string p = RTSListUtil.ToKey(n.p); if (n.s >= 2) { logs.Add(n.s > 2 ? DataLog.Create(parent, p, n.v) : DataLog.Modify(parent, p, n.v)); continue; } IDataLoggable d = n.v as IDataLoggable; if (d != null) { d.CollectChangeLogs(string.IsNullOrEmpty(parent) ? p : (parent + "." + p), logs); } } }
public void Add(T item) { if (_size == _items.Length) { EnsureCapacity(_size + 1); } double p = _size > 0 ? _items[_size - 1].p + 1.0 : 0.0; TryRegisterHandler(item); Node n = new Node(p, item, 3); _items[_size] = n; _size++; _version++; string pp = RTSListUtil.ToKey(n.p); mRemoved.Remove(pp); onModify?.Invoke(this, _size - 1); }
public void Insert(int index, T item) { if ((uint)index > (uint)_size) { throw new ArgumentOutOfRangeException("index"); } if (_size == _items.Length) { EnsureCapacity(_size + 1); } if (index < _size) { Array.Copy(_items, index, _items, index + 1, _size - index); } double p = 0.0; if (_size > 0) { if (index == 0) { p = _items[1].p - 1.0; } else if (index == _size) { p = _items[_size].p + 1.0; } else { p = (_items[index - 1].p + _items[index + 1].p) * 0.5; } } Node n = new Node(p, item, 3); _items[index] = n; _size++; TryRegisterHandler(item); _version++; string pp = RTSListUtil.ToKey(n.p); mRemoved.Remove(pp); onModify?.Invoke(this, index); }
public void RemoveAt(int index) { if ((uint)index >= (uint)_size) { throw new ArgumentOutOfRangeException("index"); } Node from = _items[index]; TryClearHandlers(from.v); _size--; if (index < _size) { Array.Copy(_items, index + 1, _items, index, _size - index); } Node item = _items[_size]; item.v = default(T); _items[_size] = item; _version++; string p = RTSListUtil.ToKey(from.p); mRemoved.Add(p); onModify?.Invoke(this, index); }