Exemplo n.º 1
0
        /// <summary>
        /// Updates the key/value pair position on first in MRU cache list.
        /// </summary>
        /// <param name="key"></param>
        public override sealed void Update(KeyType key, Action <KeyType, ValueType> updateAlgorithm = null)
        {
            var node = CacheList.Single(node => EqualityComparer <KeyType> .Default.Equals(node.Key, key));

            if (!IsKeyValuePairLast(key))
            {
                CacheList.Remove(node);
                CacheList.AddLast(node);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds key/value pair to MRU cache list.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public override sealed void Add(KeyType key, ValueType value, Action <KeyType, ValueType> addAlgorithm = null)
 {
     CacheList.AddLast(new KeyValuePair <KeyType, ValueType>(key, value));
 }