Time for action – creating the concurrent move-to-front list

Follow the given steps:

  1. Create a new class library project. Call it TSList.
  2. Change the name of the class from Class1.cs to ConcurrentMTFList.cs.
  3. Change the class header as follows:
    public class ConcurrentMTFList<T> where T:IComparable
  4. Add the following variable and the constructor:
    ConcurrentDictionary<T,int> _innerDS;
    ///<summary>
    ///Initializes the internal data structure.
    ///</summary>
    public ConcurrentMTFList()
    {
      _innerDS = new ConcurrentDictionary<T, int>();
    }
  5. Add the following method to add new items to the list:
    ///<summary> ///Adds an item to the concurrent list. ///</summary> ///<param name="item">item to be added.</param> public void Add(T item) { _innerDS.AddOrUpdate(item, 0, (i, ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.