Changeset 2325 for trunk/sources/HeuristicLab.SparseMatrix
- Timestamp:
- 09/02/09 12:03:13 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.SparseMatrix/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SparseMatrix/3.2/Matrix.cs
r2284 r2325 25 25 26 26 namespace HeuristicLab.SparseMatrix { 27 public class Matrix : ItemBase {27 public class Matrix<KeyType,ValueType> : ItemBase { 28 28 public Matrix() { 29 this.rows = new List<MatrixRow >();29 this.rows = new List<MatrixRow<KeyType,ValueType>>(); 30 30 } 31 31 32 public Matrix(IEnumerable<MatrixRow > rows)32 public Matrix(IEnumerable<MatrixRow<KeyType,ValueType>> rows) 33 33 : this() { 34 34 this.rows.AddRange(rows); 35 35 } 36 36 37 private List<MatrixRow > rows;38 public ReadOnlyCollection<MatrixRow > GetRows() {37 private List<MatrixRow<KeyType, ValueType>> rows; 38 public ReadOnlyCollection<MatrixRow<KeyType, ValueType>> GetRows() { 39 39 return rows.AsReadOnly(); 40 40 } 41 41 42 public void AddRow(MatrixRow row) {42 public void AddRow(MatrixRow<KeyType, ValueType> row) { 43 43 this.rows.Add(row); 44 44 } 45 45 46 public void RemoveRow(MatrixRow row) {46 public void RemoveRow(MatrixRow<KeyType, ValueType> row) { 47 47 this.rows.Remove(row); 48 48 } -
trunk/sources/HeuristicLab.SparseMatrix/3.2/MatrixRow.cs
r2288 r2325 23 23 24 24 namespace HeuristicLab.SparseMatrix { 25 public class MatrixRow {26 private Dictionary< string, object> values;25 public class MatrixRow<KeyType, ValueType> { 26 private Dictionary<KeyType, ValueType> values; 27 27 public MatrixRow() { 28 values = new Dictionary<string, object>(); 29 } 30 31 public void Set(string name, object value) { 32 values.Add(name, value); 28 values = new Dictionary<KeyType, ValueType>(); 33 29 } 34 30 35 public object Get(string name) { 36 if (name == null || !values.ContainsKey(name)) return null; 37 return values[name]; 31 public void Set(KeyType key, ValueType value) { 32 values.Add(key, value); 38 33 } 39 34 40 public IEnumerable<KeyValuePair<string, object>> Values { 35 public bool ContainsKey(KeyType key) { 36 return values.ContainsKey(key); 37 } 38 39 public ValueType Get(KeyType key) { 40 if (key == null || !values.ContainsKey(key)) return default(ValueType); 41 return values[key]; 42 } 43 44 public IEnumerable<KeyValuePair<KeyType, ValueType>> Values { 41 45 get { return values; } 42 46 }
Note: See TracChangeset
for help on using the changeset viewer.