/// <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 } }); }
/// <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; } }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }