コード例 #1
0
        public override TItem Get(string key)
        {
            if (!Store.ContainsKey(key))
            {
                return(null);
            }

            Keys.Remove(key);
            Keys.AddLast(key);
            return(Store[key]);
        }
コード例 #2
0
 public override void Put(string key, TItem value)
 {
     if (!Store.ContainsKey(key))
     {
         if (Store.Count == MaxSize)
         {
             // remove first key (the oldest)
             string keyToRemove = Keys.First();
             Keys.RemoveFirst();
             Store.Remove(keyToRemove);
         }
         Keys.AddLast(key);
         Store.Add(key, value);
     }
     else
     {
         Keys.Remove(key);
         Keys.AddLast(key);
         Store[key] = value;
     }
 }
コード例 #3
0
 public override void Put(string key, TItem value)
 {
     if (!Store.ContainsKey(key))
     {
         if (Store.Count < MaxSize)
         {
             Store.Add(key, value);
             Keys.AddLast(key);
         }
         else
         {
             string firstKey = Keys.First();
             Keys.RemoveFirst();
             Store.Remove(firstKey);
         }
     }
     else
     {
         Keys.Remove(key);
         Keys.AddLast(key);
         Store[key] = value;
     }
 }