Time for action – finding common values across different bidding amount lists

Follow the given steps:

  1. Stay in the MultiLiveSortedList class. Add the following methods:
    public SortedSet<TValue> CommonAcross
    {
      get
      {
        SortedSet<TValue> com;
        com = new SortedSet<TValue>(innerDS.Values[0].LiveSortedValues);
        for (int i = 1; i < innerDS.Count; i++)
        com.IntersectWith
        (new SortedSet<TValue>(innerDS.Values[i].LiveSortedValues));
        return com;
      }
    }
    
    public SortedSet<TValue> CommonAmong(TKey key1, TKey key2)
    {
      SortedSet<TValue> com;
      com = new SortedSet<TValue>(innerDS[key1].LiveSortedValues);
      com.IntersectWith(new SortedSet<TValue>(innerDS[key2].LiveSortedValues));
               
      return com;
    }
  2. Go to the console app previously created. Add the following snippet after the previous ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.