private bool Remove(TInput key) { bool existed = _data.Remove(key); _lruList.Remove(key); return(existed); }
public void IndexedLinkedList_Remove() { IndexedLinkedList<string> list = new IndexedLinkedList<string>(); list.AddFirst("3"); list.AddFirst("2"); list.AddFirst("1"); Assert.AreEqual(3, list.Count); Assert.AreEqual("1", list.First); list.Remove("1"); Assert.AreEqual(2, list.Count); Assert.AreEqual("2", list.First); list.Remove("3"); Assert.AreEqual(1, list.Count); Assert.AreEqual("2", list.First); }
/// <summary> /// Tries to delete entity with the specified key. /// </summary> /// <param name="entityKey">The key of the entity to delete.</param> /// <returns>true, if the entity was deleted.</returns> public bool TryDeleteEntity(TKey entityKey) { lock (_entities) { var result = _entities.Remove(entityKey); if (_gcFifoQueue != null && result) { _gcFifoQueue.Remove(entityKey); } return(result); } }
public void RemoveTest() { var list = new IndexedLinkedList<int> { 1, 0, -1 }; list.Remove(0); Assert.AreEqual(2, list.Count, "Remove failed, size does not match expected"); // Dump as array var expected = new int[] { 1, -1 }; var actual = new int[list.Count]; list.CopyTo(actual, 0); CollectionAssert.AreEqual(expected, actual, "Remove failed, The list does not match expected"); }