public void Insert(int index, T item) { DoBaseWrite(() => { WriteCollection.Insert(index, item); }); }
/// <summary> /// Adds an element with the provided key and value to the IDictionary<TKey, TValue>. /// </summary> /// <param name="key"> /// The object to use as the key of the element to add. /// </param> /// <param name="value"> /// The object to use as the value of the element to add. /// </param> protected override void BaseAdd(TKey key, TValue value) { int index = _sorter.GetInsertIndex(WriteCollection.Count, key, delegate(int testIndex) { return(WriteCollection[testIndex].Key); }); if (index >= WriteCollection.Count) { base.BaseAdd(key, value); } else { TKey listKey = WriteCollection[index].Key; DoubleLinkListIndexNode next = _keyToIndex[listKey]; DoubleLinkListIndexNode newNode = new DoubleLinkListIndexNode(next.Previous, next); _keyToIndex[key] = newNode; WriteCollection.Insert(index, new KeyValuePair <TKey, TValue>(key, value)); } }
/// <summary> /// /// </summary> /// <param name="i"></param> /// <param name="Item"></param> public void Insert(int i, T Item) { DoBaseWrite(() => WriteCollection.Insert(i, Item)); OnItemInserted(Item, i); OnItemsChanged(); }