public void LruList_RemoveOneItem() { var lruList = new LruList<string, string>(); var item1 = new LruListItem<string, string>("key1", "value1"); lruList.Add(item1); lruList.Remove(item1); AssertDisconnected(item1); AssertListState(lruList); }
public void LruList_RemoveOneItem() { var lruList = new LruList <string, string>(); var item1 = new LruListItem <string, string>("key1", "value1"); lruList.Add(item1); lruList.Remove(item1); AssertDisconnected(item1); AssertListState(lruList); }
public void LruList_RemoveTailTwoItems() { var lruList = new LruList<string, string>(); var item1 = new LruListItem<string, string>("key1", "value1"); var item2 = new LruListItem<string, string>("key2", "value2"); lruList.Add(item1); lruList.Add(item2); lruList.Remove(item1); AssertDisconnected(item1); AssertListState(lruList, item2); }
public void LruList_RemoveTailTwoItems() { var lruList = new LruList <string, string>(); var item1 = new LruListItem <string, string>("key1", "value1"); var item2 = new LruListItem <string, string>("key2", "value2"); lruList.Add(item1); lruList.Add(item2); lruList.Remove(item1); AssertDisconnected(item1); AssertListState(lruList, item2); }
protected override void InsertCore(TKey key, LinkedListNode <KeyValuePair <TKey, TValue> > newNode) { base.InsertCore(key, newNode); var value = newNode.Value.Value; // if there was a node already with same distinct value we need to remove it if (_distinctDictionary.TryGetValue(value, out var oldNode)) { LruList.Remove(oldNode); Remove(oldNode.Value.Key); } _distinctDictionary[value] = newNode; }