Beispiel #1
0
 public void Remove(LruListItem <TKey, TValue> item)
 {
     if (Head == item || Tail == item)
     {
         if (Head == item)
         {
             Head = item.Next;
             if (Head != null)
             {
                 Head.Previous = null;
             }
         }
         if (Tail == item)
         {
             Tail = item.Previous;
             if (Tail != null)
             {
                 Tail.Next = null;
             }
         }
     }
     else
     {
         item.Previous.Next = item.Next;
         item.Next.Previous = item.Previous;
     }
     item.Previous = null;
     item.Next     = null;
 }
Beispiel #2
0
 public void LruList_AddEmpty()
 {
     var lruList = new LruList<string, string>();
     var item1 = new LruListItem<string, string>("key1", "value1");
     lruList.Add(item1);
     AssertListState(lruList, item1);
 }
Beispiel #3
0
        public void LruList_AddEmpty()
        {
            var lruList = new LruList <string, string>();
            var item1   = new LruListItem <string, string>("key1", "value1");

            lruList.Add(item1);
            AssertListState(lruList, item1);
        }
Beispiel #4
0
 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);
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 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);
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 public void Add(LruListItem <TKey, TValue> item)
 {
     if (Head == null)
     {
         Head          = item;
         Tail          = item;
         item.Previous = null;
         item.Next     = null;
     }
     else
     {
         Head.Previous = item;
         item.Next     = Head;
         item.Previous = null;
         Head          = item;
     }
 }
Beispiel #9
0
 internal void Clear()
 {
     Head = null;
     Tail = null;
 }
Beispiel #10
0
 public void Touch(LruListItem <TKey, TValue> item)
 {
     Remove(item);
     Add(item);
 }
Beispiel #11
0
 private void AssertDisconnected(LruListItem<string, string> item)
 {
     Assert.IsNull(item.Previous);
     Assert.IsNull(item.Next);
 }
Beispiel #12
0
 private void AssertDisconnected(LruListItem <string, string> item)
 {
     Assert.IsNull(item.Previous);
     Assert.IsNull(item.Next);
 }