equal
deleted
inserted
replaced
25 #include <lemon/maps.h> |
25 #include <lemon/maps.h> |
26 |
26 |
27 #include <lemon/concept/matrix_maps.h> |
27 #include <lemon/concept/matrix_maps.h> |
28 |
28 |
29 /// \file |
29 /// \file |
30 /// \ingroup maps |
30 /// \ingroup matrices |
31 /// \brief Maps indexed with pairs of items. |
31 /// \brief Maps indexed with pairs of items. |
32 /// |
32 /// |
33 /// \todo This file has the same name as the concept file in concept/, |
33 /// \todo This file has the same name as the concept file in concept/, |
34 /// and this is not easily detectable in docs... |
34 /// and this is not easily detectable in docs... |
35 namespace lemon { |
35 namespace lemon { |
36 |
36 |
37 /// \brief Map for the coloumn view of the matrix |
37 /// \brief Map for the coloumn view of the matrix |
38 /// |
38 /// |
|
39 /// \ingroup matrices |
39 /// Map for the coloumn view of the matrix. |
40 /// Map for the coloumn view of the matrix. |
|
41 /// |
40 template <typename _MatrixMap> |
42 template <typename _MatrixMap> |
41 class MatrixRowMap : public MatrixMapTraits<_MatrixMap> { |
43 class MatrixRowMap : public MatrixMapTraits<_MatrixMap> { |
42 public: |
44 public: |
43 typedef _MatrixMap MatrixMap; |
45 typedef _MatrixMap MatrixMap; |
44 typedef typename MatrixMap::SecondKey Key; |
46 typedef typename MatrixMap::SecondKey Key; |
76 typename MatrixMap::FirstKey row; |
78 typename MatrixMap::FirstKey row; |
77 }; |
79 }; |
78 |
80 |
79 /// \brief Map for the row view of the matrix |
81 /// \brief Map for the row view of the matrix |
80 /// |
82 /// |
|
83 /// \ingroup matrices |
81 /// Map for the row view of the matrix. |
84 /// Map for the row view of the matrix. |
|
85 /// |
82 template <typename _MatrixMap> |
86 template <typename _MatrixMap> |
83 class ConstMatrixRowMap : public MatrixMapTraits<_MatrixMap> { |
87 class ConstMatrixRowMap : public MatrixMapTraits<_MatrixMap> { |
84 public: |
88 public: |
85 typedef _MatrixMap MatrixMap; |
89 typedef _MatrixMap MatrixMap; |
86 typedef typename MatrixMap::SecondKey Key; |
90 typedef typename MatrixMap::SecondKey Key; |
104 typename MatrixMap::FirstKey row; |
108 typename MatrixMap::FirstKey row; |
105 }; |
109 }; |
106 |
110 |
107 /// \brief Gives back a row view of the matrix map |
111 /// \brief Gives back a row view of the matrix map |
108 /// |
112 /// |
|
113 /// \ingroup matrices |
109 /// Gives back a row view of the matrix map. |
114 /// Gives back a row view of the matrix map. |
|
115 /// |
110 template <typename MatrixMap> |
116 template <typename MatrixMap> |
111 MatrixRowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap, |
117 MatrixRowMap<MatrixMap> matrixRowMap(MatrixMap& matrixMap, |
112 typename MatrixMap::FirstKey row) { |
118 typename MatrixMap::FirstKey row) { |
113 return MatrixRowMap<MatrixMap>(matrixMap, row); |
119 return MatrixRowMap<MatrixMap>(matrixMap, row); |
114 } |
120 } |
117 ConstMatrixRowMap<MatrixMap> |
123 ConstMatrixRowMap<MatrixMap> |
118 matrixRowMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey row) { |
124 matrixRowMap(const MatrixMap& matrixMap, typename MatrixMap::FirstKey row) { |
119 return ConstMatrixRowMap<MatrixMap>(matrixMap, row); |
125 return ConstMatrixRowMap<MatrixMap>(matrixMap, row); |
120 } |
126 } |
121 |
127 |
122 /// \brief Map for the row view of the matrix |
128 /// \brief Map for the column view of the matrix |
123 /// |
129 /// |
124 /// Map for the row view of the matrix. |
130 /// \ingroup matrices |
|
131 /// Map for the column view of the matrix. |
|
132 /// |
125 template <typename _MatrixMap> |
133 template <typename _MatrixMap> |
126 class MatrixColMap : public MatrixMapTraits<_MatrixMap> { |
134 class MatrixColMap : public MatrixMapTraits<_MatrixMap> { |
127 public: |
135 public: |
128 typedef _MatrixMap MatrixMap; |
136 typedef _MatrixMap MatrixMap; |
129 typedef typename MatrixMap::FirstKey Key; |
137 typedef typename MatrixMap::FirstKey Key; |
158 private: |
166 private: |
159 MatrixMap& matrix; |
167 MatrixMap& matrix; |
160 typename MatrixMap::SecondKey col; |
168 typename MatrixMap::SecondKey col; |
161 }; |
169 }; |
162 |
170 |
163 /// \brief Map for the col view of the matrix |
171 /// \brief Map for the column view of the matrix |
164 /// |
172 /// |
165 /// Map for the col view of the matrix. |
173 /// \ingroup matrices |
|
174 /// Map for the column view of the matrix. |
|
175 /// |
166 template <typename _MatrixMap> |
176 template <typename _MatrixMap> |
167 class ConstMatrixColMap : public MatrixMapTraits<_MatrixMap> { |
177 class ConstMatrixColMap : public MatrixMapTraits<_MatrixMap> { |
168 public: |
178 public: |
169 typedef _MatrixMap MatrixMap; |
179 typedef _MatrixMap MatrixMap; |
170 typedef typename MatrixMap::FirstKey Key; |
180 typedef typename MatrixMap::FirstKey Key; |
185 private: |
195 private: |
186 const MatrixMap& matrix; |
196 const MatrixMap& matrix; |
187 typename MatrixMap::SecondKey col; |
197 typename MatrixMap::SecondKey col; |
188 }; |
198 }; |
189 |
199 |
190 /// \brief Gives back a col view of the matrix map |
200 /// \brief Gives back a column view of the matrix map |
191 /// |
201 /// |
192 /// Gives back a col view of the matrix map. |
202 /// \ingroup matrices |
|
203 /// Gives back a column view of the matrix map. |
|
204 /// |
193 template <typename MatrixMap> |
205 template <typename MatrixMap> |
194 MatrixColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap, |
206 MatrixColMap<MatrixMap> matrixColMap(MatrixMap& matrixMap, |
195 typename MatrixMap::SecondKey col) { |
207 typename MatrixMap::SecondKey col) { |
196 return MatrixColMap<MatrixMap>(matrixMap, col); |
208 return MatrixColMap<MatrixMap>(matrixMap, col); |
197 } |
209 } |
202 return ConstMatrixColMap<MatrixMap>(matrixMap, col); |
214 return ConstMatrixColMap<MatrixMap>(matrixMap, col); |
203 } |
215 } |
204 |
216 |
205 /// \brief Container for store values for each ordered pair of graph items |
217 /// \brief Container for store values for each ordered pair of graph items |
206 /// |
218 /// |
|
219 /// \ingroup matrices |
207 /// This data structure can strore for each pair of the same item |
220 /// This data structure can strore for each pair of the same item |
208 /// type a value. It increase the size of the container when the |
221 /// type a value. It increase the size of the container when the |
209 /// associated graph modified, so it updated automaticly whenever |
222 /// associated graph modified, so it updated automaticly whenever |
210 /// it is needed. |
223 /// it is needed. |
211 template <typename _Graph, typename _Item, typename _Value> |
224 template <typename _Graph, typename _Item, typename _Value> |
336 std::vector<Value> values; |
349 std::vector<Value> values; |
337 }; |
350 }; |
338 |
351 |
339 /// \brief Container for store values for each unordered pair of graph items |
352 /// \brief Container for store values for each unordered pair of graph items |
340 /// |
353 /// |
|
354 /// \ingroup matrices |
341 /// This data structure can strore for each pair of the same item |
355 /// This data structure can strore for each pair of the same item |
342 /// type a value. It increase the size of the container when the |
356 /// type a value. It increase the size of the container when the |
343 /// associated graph modified, so it updated automaticly whenever |
357 /// associated graph modified, so it updated automaticly whenever |
344 /// it is needed. |
358 /// it is needed. |
345 template <typename _Graph, typename _Item, typename _Value> |
359 template <typename _Graph, typename _Item, typename _Value> |
386 |
400 |
387 |
401 |
388 ///\brief The assignement operator. |
402 ///\brief The assignement operator. |
389 /// |
403 /// |
390 ///It allow to assign a map to an other. |
404 ///It allow to assign a map to an other. |
|
405 /// |
391 DynamicSymMatrixMap& operator=(const DynamicSymMatrixMap& _cmap){ |
406 DynamicSymMatrixMap& operator=(const DynamicSymMatrixMap& _cmap){ |
392 return operator=<DynamicSymMatrixMap>(_cmap); |
407 return operator=<DynamicSymMatrixMap>(_cmap); |
393 } |
408 } |
394 |
409 |
395 ///\brief Template assignement operator. |
410 ///\brief Template assignement operator. |
433 } |
448 } |
434 |
449 |
435 /// \brief Setter function for the matrix map. |
450 /// \brief Setter function for the matrix map. |
436 /// |
451 /// |
437 /// Setter function for the matrix map. |
452 /// Setter function for the matrix map. |
|
453 /// |
438 void set(const Key& first, const Key& second, const Value& val) { |
454 void set(const Key& first, const Key& second, const Value& val) { |
439 values[index(Parent::getNotifier()->id(first), |
455 values[index(Parent::getNotifier()->id(first), |
440 Parent::getNotifier()->id(second))] = val; |
456 Parent::getNotifier()->id(second))] = val; |
441 } |
457 } |
442 |
458 |
474 std::vector<Value> values; |
490 std::vector<Value> values; |
475 }; |
491 }; |
476 |
492 |
477 ///\brief Dynamic Asymmetric Matrix Map. |
493 ///\brief Dynamic Asymmetric Matrix Map. |
478 /// |
494 /// |
|
495 ///\ingroup matrices |
479 ///Dynamic Asymmetric Matrix Map. Container for store values for each |
496 ///Dynamic Asymmetric Matrix Map. Container for store values for each |
480 ///ordered pair of containers items. This data structure can store |
497 ///ordered pair of containers items. This data structure can store |
481 ///data with different key types from different container types. It |
498 ///data with different key types from different container types. It |
482 ///increases the size of the container if the linked containers |
499 ///increases the size of the container if the linked containers |
483 ///content change, so it is updated automaticly whenever it is |
500 ///content change, so it is updated automaticly whenever it is |
609 } |
626 } |
610 private: |
627 private: |
611 |
628 |
612 ///The map type for it is linked. |
629 ///The map type for it is linked. |
613 DynamicAsymMatrixMap& _owner; |
630 DynamicAsymMatrixMap& _owner; |
614 };///END OF FIRSTKEYPROXY |
631 };//END OF FIRSTKEYPROXY |
615 |
632 |
616 ///\brief Proxy class for the second key type. |
633 ///\brief Proxy class for the second key type. |
617 /// |
634 /// |
618 ///The proxy class belongs to the SecondKey type. It is |
635 ///The proxy class belongs to the SecondKey type. It is |
619 ///necessary because if one want use the same conatainer types |
636 ///necessary because if one want use the same conatainer types |
695 } |
712 } |
696 private: |
713 private: |
697 |
714 |
698 ///The type of map for which it is attached. |
715 ///The type of map for which it is attached. |
699 DynamicAsymMatrixMap& _owner; |
716 DynamicAsymMatrixMap& _owner; |
700 };///END OF SECONDKEYPROXY |
717 };//END OF SECONDKEYPROXY |
701 |
718 |
702 private: |
719 private: |
703 |
720 |
704 /// \e |
721 /// \e |
705 typedef std::vector<Value> Container; |
722 typedef std::vector<Value> Container; |