private void SetHelper(uint index, T value) { if (_listChanging != null) { CallListChanging(new ListChangeInfo <T>(NotifyCollectionChangedAction.Replace, (int)index, 0, ListExt.Single(value))); } ++_version; if (_root.IsFrozen) { AutoCreateOrCloneRoot(); } _root.SetAt(index, value, _observer); CheckPoint(); }
public sealed override void Insert(int index, T item) { if ((uint)index > (uint)_count) { throw new IndexOutOfRangeException(); } DetectSizeOverflow(1); AutoThrow(); if (_listChanging != null) { CallListChanging(new ListChangeInfo <T>(NotifyCollectionChangedAction.Add, index, 1, ListExt.Single(item))); } try { _freezeMode = FrozenForConcurrency; if (_root == null || _root.IsFrozen) { AutoCreateOrCloneRoot(); } AListNode <int, T> splitLeft, splitRight; splitLeft = _root.Insert((uint)index, item, out splitRight, _observer); if (splitLeft != null) // redundant 'if' optimization { AutoSplit(splitLeft, splitRight); } ++_version; Debug.Assert(_count != int.MaxValue); ++_count; CheckPoint(); } finally { _freezeMode = NotFrozen; } }