本文整理汇总了C#中LruCache.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# LruCache.ContainsKey方法的具体用法?C# LruCache.ContainsKey怎么用?C# LruCache.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LruCache
的用法示例。
在下文中一共展示了LruCache.ContainsKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add_ItemIsAdded_ItemExistsInCache
public void Add_ItemIsAdded_ItemExistsInCache()
{
var lru = new LruCache<string, string>(1);
lru.Add("k1", "v1");
Assert.IsTrue(lru.ContainsKey("k1"));
}
示例2: Add_MaxSizeIsReached_OldestItemDiscarded
public void Add_MaxSizeIsReached_OldestItemDiscarded()
{
var lru = new LruCache<string, string>(5);
lru.Add("k1", "v1");
lru.Add("k2", "v2");
lru.Add("k3", "v3");
lru.Add("k4", "v4");
lru.Add("k5", "v5");
lru.Add("k6", "v6");
Assert.IsFalse(lru.ContainsKey("k1"));
}
示例3: TestSizeIsLimited
public void TestSizeIsLimited()
{
var cache = new LruCache<string, int>(10);
for (int i = 0; i < 20; i++) {
cache[i.ToString()] = i;
}
Assert.AreEqual(10, cache.Count);
for (int i = 10; i < 20; i++) {
Assert.IsTrue(cache.ContainsKey(i.ToString()));
}
}
示例4: CacheAccessShouldBumpItToTheFront
public void CacheAccessShouldBumpItToTheFront()
{
var cache = new LruCache<int, int>(3);
cache[1] = 1;
cache[2] = 2;
cache[3] = 3;
var a = cache[1];
cache[4] = 4;
Assert.AreEqual(cache[1], 1);
Assert.AreEqual(cache[3], 3);
Assert.AreEqual(cache[4], 4);
Assert.IsFalse(cache.ContainsKey(2));
}
示例5: Resize_NewSizeCausesTrim_OnlyOldestItemsDiscarded
public void Resize_NewSizeCausesTrim_OnlyOldestItemsDiscarded()
{
var lru = new LruCache<string, string>(5);
lru.Add("k1", "v1");
lru.Add("k2", "v2");
lru.Add("k3", "v3");
lru.Add("k4", "v4");
lru.Add("k5", "v5");
lru.Resize(3);
Assert.IsFalse(lru.ContainsKey("k1"));
Assert.IsFalse(lru.ContainsKey("k2"));
Assert.IsTrue(lru.ContainsKey("k3"));
Assert.IsTrue(lru.ContainsKey("k4"));
Assert.IsTrue(lru.ContainsKey("k5"));
}
示例6: Remove_ItemIsRemoved_ContainsKeyReturnsFalse
public void Remove_ItemIsRemoved_ContainsKeyReturnsFalse()
{
var lru = new LruCache<string, string>(1);
lru.Add("k1", "v1");
lru.Remove("k1");
Assert.IsFalse(lru.ContainsKey("k1"));
}
示例7: ContainsKey_KeyExists_ReturnsTrue
public void ContainsKey_KeyExists_ReturnsTrue()
{
var lru = new LruCache<string, string>(1);
lru.Add("k1", "v1");
Assert.IsTrue(lru.ContainsKey("k1"));
}
示例8: ContainsKey_KeyDoestNotExist_ReturnsFalse
public void ContainsKey_KeyDoestNotExist_ReturnsFalse()
{
var lru = new LruCache<string, string>(1);
Assert.IsFalse(lru.ContainsKey("k1"));
}