Exemplo n.º 1
0
 /// <summary>
 ///     Adds the given Column, Row, and value to the table.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void Add(ColumnRowPair <TRow, TColumn> key, TValue value)
 {
     lookup.Add(key.Row,
                new KeyedDictionary <TColumn, TValue>
     {
         { key.Column, value }
     });
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Gets or sets the value of the value at the given column and row.
 ///     Returns default(TValue) if the key cannot be found.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public TValue this[ColumnRowPair <TRow, TColumn> key]
 {
     get
     {
         TValue result;
         TryGetValue(key, out result);
         return(result);
     }
     set { lookup[key.Row][key.Column] = value; }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Tries to get a value based on the given key,
        ///     Returns true if the operation was successful, otherwise false.
        ///     value is set to the found value or default(T).
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool TryGetValue(ColumnRowPair <TRow, TColumn> key, out TValue value)
        {
            KeyedDictionary <TColumn, TValue> v;

            if (!lookup.TryGetValue(key.Row, out v))
            {
                return(v.TryGetValue(key.Column, out value));
            }
            value = default(TValue);
            return(false);
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Removes the column/row/value from the table based on the key.
 ///     Returns false if the key does not exist in the dictionary.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool Remove(ColumnRowPair <TRow, TColumn> key)
 {
     return(lookup[key.Row].Remove(key.Column));
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Determines if the given Column Row Pair is contained in the Table.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool ContainsKey(ColumnRowPair <TRow, TColumn> key)
 {
     return(lookup.ContainsKey(key.Row) && lookup[key.Row].ContainsKey(key.Column));
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Determines if this column row pair object is equal to the given other object.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(ColumnRowPair <TRow, TColumn> other)
 {
     return(other.Row.Equals(Row) && other.Column.Equals(Column));
 }