Example #1
0
 /// <summary>
 /// Allow indexing into the matrix based on the matrix key
 /// <para>i.e. Matrix<</para>
 /// <example>Matrix<T1,T2,V> mat = new Matrix<T1,T2,V>();
 /// var key = new MatrixKey<T1,T2>(hval, vval);
 /// V x = mat[key];
 /// mat[key] = x;</example>
 /// </summary>
 /// <param name="key">The key for the matrix</param>
 /// <returns>The value in the matrix at the particular key reference point</returns>
 public T this[MatrixKey <HType, VType> key]
 {
     get
     {
         return(MatrixMap[key]);
     }
     private set
     {
         MatrixMap[key] = value;
     }
 }
Example #2
0
        public override bool Equals(object obj)
        {
            MatrixKey <HType, VType> rhs = obj as MatrixKey <HType, VType>;

            if (rhs == null)
            {
                return(false);
            }

            return(HorizontalKey.Equals(rhs.HorizontalKey) &&
                   VerticalKey.Equals(rhs.VerticalKey));
        }
Example #3
0
        /// <summary>
        /// Add a value into the matrix based on the supplied key values.
        /// <para>If both key types are of the same base type then
        /// a reverse key entry will also be added into the matrix</para>
        /// </summary>
        /// <param name="hKey">The key for the horizontal axis of the matrix</param>
        /// <param name="vKey">The key for the vertical axis of the matrix</param>
        /// <param name="value">The value to be stored in the matrix at the keyed position</param>
        public void Add(HType hKey, VType vKey, T value)
        {
            MatrixKey <HType, VType> key = new MatrixKey <HType, VType>(hKey, vKey);

            MatrixMap[key] = value;
            // If both keys are of the same type then also add them reversed into the matrix
            if (hKey is VType)
            {
                key            = new MatrixKey <HType, VType>(vKey as HType, hKey as VType);
                MatrixMap[key] = value;
            }
        }
Example #4
0
 /// <summary>
 /// Allow indexing into the matrix using the horizontal and vertical index
 /// references as parameters without requiring key construction
 /// </summary>
 /// <param name="hKey">The horizontal index value</param>
 /// <param name="vKey">The vertical index value</param>
 /// <returns>The value in the matrix at the particular reference point</returns>
 public T this[HType hKey, VType vKey]
 {
     get
     {
         MatrixKey <HType, VType> key = new MatrixKey <HType, VType>(hKey, vKey);
         return(this[key]);
     }
     private set
     {
         MatrixKey <HType, VType> key = new MatrixKey <HType, VType>(hKey, vKey);
         this[key] = value;
     }
 }