
using System.Collections.Generic;
using System;

namespace CellTemplateProblem
{
    internal class RowItem : IComparable
    {
        private readonly Dictionary<int, CombinedItem> _itemsByColumnId = new Dictionary<int, CombinedItem>();

        public int Id { get; set; }

        public CombinedItem GetItemForColumn(int col)
        {
            if (!_itemsByColumnId.ContainsKey(col))
            {
                _itemsByColumnId[col] = new CombinedItem(Id, col, string.Format("R{0}C{1}", Id, col));
            }

            return _itemsByColumnId[col];
        }

        public int CompareTo(object obj)
        {
            return this.Id - (obj as RowItem).Id;
        }
    }    
}
