Example #1
0
 public bool Equals(SparseMatrixNode n)
 {
     if (n == null)
     {
         return(false);
     }
     return((col == n.col) && (row == n.row));
 }
Example #2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            SparseMatrixNode n = obj as SparseMatrixNode;

            if (n == null)
            {
                return(false);
            }
            return((col == n.col) && (row == n.row));
        }
Example #3
0
        private bool SetValue(int row, int col, int value)
        {
            if ((row > height) || (col > width))
            {
                return(false);
            }
            SparseMatrixNode n = new SparseMatrixNode(row, col, value);

            if (sparse_matrix[row].Find(n) == null)
            {
                sparse_matrix[row].AddLast(n); return(true);
            }
            else
            {
                sparse_matrix[row].Find(n).Value.value = value; return(true);
            }
        }
Example #4
0
        private int GetValue(int row, int col)
        {
            if ((row > height) || (col > width))
            {
                return(-1);
            }
            SparseMatrixNode n = new SparseMatrixNode(row, col, 0);

            if (sparse_matrix[row].Find(n) == null)
            {
                return(-1);
            }
            SparseMatrixNode m = sparse_matrix[row].Find(n).Value;

            if (m == null)
            {
                return(-1);
            }
            return(m.value);
        }