Changeset 1536:308150155bb5 in lemon-0.x
- Timestamp:
- 07/04/05 18:27:54 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2028
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/groups.dox
r1402 r1536 67 67 Map adaptors are used to create "implicit" maps from other maps. 68 68 69 Most of them are \ref concept::ReadMap "ReadMap"s. They can69 Most of them are \ref lemon::concept::ReadMap "ReadMap"s. They can 70 70 make arithmetic oprerations between one or two maps (negation, scalig, 71 71 addition, multiplication etc.) or e.g. convert a map to another one -
doc/license.dox
r996 r1536 3 3 \page license License Terms 4 4 5 \verbinclude ../ ../LICENSE5 \verbinclude ../LICENSE 6 6 7 7 */ -
doc/named-param.dox
r1438 r1536 5 5 \section named-func-param Named "Function" Parameters 6 6 7 C++ makes it possible to use default parameter values when calling a function. In such 8 a case we do not have to give value for parameters, the program will use the default ones. 9 Unfortunately sometimes this is not enough. If we do not want to give values for all the parameters, only 10 for some of them we come across problems, because an arbitrary set of parameters cannot be omitted. On the other hand parameters have a fixed order in the head of the function. 11 C++ can apply the default values only in the back of the order, if we do not give other value for them. 12 So we can not give the function for example the value of the first, and the third parameter, expecting that the program will aplly the default value for the second parameter. 13 However sometimes we would like to use some functinos exactly in this way. With a crafty trick and with some little inconvenience this is possible. We have implemented this little trick as an example below. 7 C++ makes it possible to use default parameter values when calling a 8 function. In such a case we do not have to give value for parameters, 9 the program will use the default ones. Unfortunately sometimes this 10 is not enough. If we do not want to give values for all the 11 parameters, only for some of them we come across problems, because an 12 arbitrary set of parameters cannot be omitted. On the other hand 13 parameters have a fixed order in the head of the function. C++ can 14 apply the default values only in the back of the order, if we do not 15 give other value for them. So we can not give the function for 16 example the value of the first, and the third parameter, expecting 17 that the program will aplly the default value for the second 18 parameter. However sometimes we would like to use some functinos 19 exactly in this way. With a crafty trick and with some little 20 inconvenience this is possible. We have implemented this little trick 21 as an example below. 14 22 15 23 \code … … 35 43 The usage is the following. 36 44 37 We have to define a class, let's call it named_fn. 38 Let us assume that we would like to use a parameter, called X. In the named_fn class we have to define an _X attribute, and an X function. The function expects a parameter with the type of _X, and sets the value of _X. After setting the value the function returns the class itself. The class also have to have a function, called for example run(), we have to implement here the original function itself. The constructor of the class have to give all the attributes like _X the default values of them. 45 We have to define a class, let's call it named_fn. Let us assume that 46 we would like to use a parameter, called X. In the named_fn class we 47 have to define an _X attribute, and an X function. The function 48 expects a parameter with the type of _X, and sets the value of 49 _X. After setting the value the function returns the class itself. The 50 class also have to have a function, called for example run(), we have 51 to implement here the original function itself. The constructor of the 52 class have to give all the attributes like _X the default values of 53 them. 39 54 40 If we instantiate this class, the default values will be set for the attributes (originally the parameters), initially. If we call the X function, we get a class with the modified parameter value of X. Therefore we can modify any parameter-value, independent from the order. To run the algorithm we have to call the run() function at the end of the row. 55 If we instantiate this class, the default values will be set for the 56 attributes (originally the parameters), initially. If we call the X 57 function, we get a class with the modified parameter value of 58 X. Therefore we can modify any parameter-value, independent from the 59 order. To run the algorithm we have to call the run() function at the 60 end of the row. 41 61 42 62 Example: named_fn().id(3).val(2).run(); … … 44 64 \section traits-classes Traits Classes 45 65 46 The procedure above can also be applied when defining classes. In this case the type of the attributes can be changed. 47 Initially we have to define a class with the default attribute types. This is the so called Traits Class. Later on 48 the types of these attributes can be changed, as described below. In our software \ref DijkstraDefaultTraits is an example of how a traits class looks like. 66 The procedure above can also be applied when defining classes. In this 67 case the type of the attributes can be changed. Initially we have to 68 define a class with the default attribute types. This is the so called 69 Traits Class. Later on the types of these attributes can be changed, 70 as described below. In our software \ref lemon::DijkstraDefaultTraits is an 71 example of how a traits class looks like. 49 72 50 73 \section named-templ-param Named Class Template Parameters 51 74 52 If we would like to change the type of an attribute in a class that was instantiated by using a traits class as a template parameter, and the class contains named parameters, we do not have to reinstantiate the class with new traits class. Instead of that, adaptor classes can be used like in the following cases. 75 If we would like to change the type of an attribute in a class that 76 was instantiated by using a traits class as a template parameter, and 77 the class contains named parameters, we do not have to reinstantiate 78 the class with new traits class. Instead of that, adaptor classes can 79 be used like in the following cases. 53 80 54 81 \code … … 63 90 \endcode 64 91 65 The result will be an instantiated Dijkstra class, in which the DistMap and the PredMap is modified. 92 The result will be an instantiated Dijkstra class, in which the 93 DistMap and the PredMap is modified. 66 94 67 95 \section named-templ-func-param Named "Function" Template Parameters 68 96 69 If the class has so called wizard functions, the new class with the modified tpye of attributes can be returned 70 by the appropriate wizard function. The usage of these wizard functions is the following: 97 If the class has so called wizard functions, the new class with the 98 modified tpye of attributes can be returned by the appropriate wizard 99 function. The usage of these wizard functions is the following: 71 100 72 101 */ -
lemon/bfs.h
r1516 r1536 85 85 86 86 ///This function instantiates a \ref ProcessedMap. 87 ///\param Gis the graph, to which87 ///\param g is the graph, to which 88 88 ///we would like to define the \ref ProcessedMap 89 #ifdef DOXYGEN 90 static ProcessedMap *createProcessedMap(const GR &g) 91 #else 89 92 static ProcessedMap *createProcessedMap(const GR &) 93 #endif 90 94 { 91 95 return new ProcessedMap(); … … 660 664 661 665 ///This function copies the shortest path to \c t into \c p. 662 ///If it \c \t is a source itself or unreachable, then it does not666 ///If \c t is a source itself or unreachable, then it does not 663 667 ///alter \c p. 664 668 ///\todo Is it the right way to handle unreachable nodes? … … 771 775 772 776 ///This function instantiates a \ref PredMap. 773 ///\param Gis the graph, to which we would like to define the PredMap.777 ///\param g is the graph, to which we would like to define the PredMap. 774 778 ///\todo The graph alone may be insufficient to initialize 779 #ifdef DOXYGEN 780 static PredMap *createPredMap(const GR &g) 781 #else 775 782 static PredMap *createPredMap(const GR &) 783 #endif 776 784 { 777 785 return new PredMap(); … … 804 812 805 813 ///This function instantiates a \ref ProcessedMap. 806 ///\param Gis the graph, to which814 ///\param g is the graph, to which 807 815 ///we would like to define the \ref ProcessedMap 816 #ifdef DOXYGEN 817 static ProcessedMap *createProcessedMap(const GR &g) 818 #else 808 819 static ProcessedMap *createProcessedMap(const GR &) 820 #endif 809 821 { 810 822 return new ProcessedMap(); … … 834 846 835 847 ///This function instantiates a \ref DistMap. 836 ///\param G is the graph, to which we would like to define the \ref DistMap 848 ///\param g is the graph, to which we would like to define the \ref DistMap 849 #ifdef DOXYGEN 850 static DistMap *createDistMap(const GR &g) 851 #else 837 852 static DistMap *createDistMap(const GR &) 853 #endif 838 854 { 839 855 return new DistMap(); -
lemon/dfs.h
r1529 r1536 85 85 86 86 ///This function instantiates a \ref ProcessedMap. 87 ///\param Gis the graph, to which87 ///\param g is the graph, to which 88 88 ///we would like to define the \ref ProcessedMap 89 #ifdef DOXYGEN 90 static ProcessedMap *createProcessedMap(const GR &g) 91 #else 89 92 static ProcessedMap *createProcessedMap(const GR &) 93 #endif 90 94 { 91 95 return new ProcessedMap(); … … 780 784 781 785 ///This function instantiates a \ref PredMap. 782 ///\param Gis the graph, to which we would like to define the PredMap.786 ///\param g is the graph, to which we would like to define the PredMap. 783 787 ///\todo The graph alone may be insufficient to initialize 788 #ifdef DOXYGEN 789 static PredMap *createPredMap(const GR &g) 790 #else 784 791 static PredMap *createPredMap(const GR &) 792 #endif 785 793 { 786 794 return new PredMap(); … … 813 821 814 822 ///This function instantiates a \ref ProcessedMap. 815 ///\param Gis the graph, to which823 ///\param g is the graph, to which 816 824 ///we would like to define the \ref ProcessedMap 825 #ifdef DOXYGEN 826 static ProcessedMap *createProcessedMap(const GR &g) 827 #else 817 828 static ProcessedMap *createProcessedMap(const GR &) 829 #endif 818 830 { 819 831 return new ProcessedMap(); … … 843 855 844 856 ///This function instantiates a \ref DistMap. 845 ///\param G is the graph, to which we would like to define the \ref DistMap 857 ///\param g is the graph, to which we would like to define the \ref DistMap 858 #ifdef DOXYGEN 859 static DistMap *createDistMap(const GR &g) 860 #else 846 861 static DistMap *createDistMap(const GR &) 862 #endif 847 863 { 848 864 return new DistMap(); -
lemon/dijkstra.h
r1516 r1536 109 109 110 110 ///This function instantiates a \ref ProcessedMap. 111 ///\param Gis the graph, to which111 ///\param g is the graph, to which 112 112 ///we would like to define the \ref ProcessedMap 113 #ifdef DOXYGEN 114 static ProcessedMap *createProcessedMap(const GR &g) 115 #else 113 116 static ProcessedMap *createProcessedMap(const GR &) 117 #endif 114 118 { 115 119 return new ProcessedMap(); … … 664 668 665 669 ///This function copies the shortest path to \c t into \c p. 666 ///If it \c \t is a source itself or unreachable, then it does not670 ///If it \c t is a source itself or unreachable, then it does not 667 671 ///alter \c p. 668 672 ///\todo Is it the right way to handle unreachable nodes? … … 789 793 790 794 ///This function instantiates a \ref PredMap. 791 ///\param Gis the graph, to which we would like to define the PredMap.795 ///\param g is the graph, to which we would like to define the PredMap. 792 796 ///\todo The graph alone may be insufficient for the initialization 797 #ifdef DOXYGEN 798 static PredMap *createPredMap(const GR &g) 799 #else 793 800 static PredMap *createPredMap(const GR &) 801 #endif 794 802 { 795 803 return new PredMap(); … … 807 815 808 816 ///This function instantiates a \ref ProcessedMap. 809 ///\param Gis the graph, to which817 ///\param g is the graph, to which 810 818 ///we would like to define the \ref ProcessedMap 819 #ifdef DOXYGEN 820 static ProcessedMap *createProcessedMap(const GR &g) 821 #else 811 822 static ProcessedMap *createProcessedMap(const GR &) 823 #endif 812 824 { 813 825 return new ProcessedMap(); … … 822 834 823 835 ///This function instantiates a \ref DistMap. 824 ///\param G is the graph, to which we would like to define the \ref DistMap 836 ///\param g is the graph, to which we would like to define the \ref DistMap 837 #ifdef DOXYGEN 838 static DistMap *createDistMap(const GR &g) 839 #else 825 840 static DistMap *createDistMap(const GR &) 841 #endif 826 842 { 827 843 return new DistMap(); -
lemon/error.h
r1435 r1536 101 101 protected: 102 102 ///\e 103 ///\todo The good solution is boost:shared_ptr... 103 104 ///\todo The good solution is boost::shared_ptr... 105 /// 104 106 mutable 105 107 std::auto_ptr<std::ostringstream> buf; -
lemon/graph_adaptor.h
r1472 r1536 452 452 of edge-disjoint paths between \c s and \c t in the graph which has edge-set 453 453 all the tight edges. The computation will be demonstrated on the following 454 graph, which is read from the dimacs file \ refsub_graph_adaptor_demo.dim.454 graph, which is read from the dimacs file \c sub_graph_adaptor_demo.dim. 455 455 The full source code is available in \ref sub_graph_adaptor_demo.cc. 456 456 If you are interested in more demo programs, you can use -
lemon/graph_utils.h
r1531 r1536 178 178 /// } 179 179 /// \endcode 180 /// \todo We may want to use the \ref concept::GraphBase"GraphBase"180 /// \todo We may want to use the "GraphBase" 181 181 /// interface here... 182 182 /// \bug Untested ... … … 860 860 /// 861 861 /// The subscript operator. 862 /// \param e dgeThe edge862 /// \param e The edge 863 863 /// \return The target of the edge 864 Value operator[](const Key& key) {865 return graph.target( key);864 Value operator[](const Key& e) { 865 return graph.target(e); 866 866 } 867 867 -
lemon/lp_base.h
r1508 r1536 400 400 401 401 ///\return 402 ///- -\ref INF: the constraint is lower unbounded.403 ///- -\ref NaN: lower bound has not been set.402 ///- \ref INF "INF": the constraint is lower unbounded. 403 ///- \ref NaN "NaN": lower bound has not been set. 404 404 ///- finite number: the lower bound 405 405 Value &lowerBound() { return _lb; } … … 409 409 410 410 ///\return 411 ///- -\ref INF: the constraint is upper unbounded.412 ///- -\ref NaN: upper bound has not been set.411 ///- \ref INF "INF": the constraint is upper unbounded. 412 ///- \ref NaN "NaN": upper bound has not been set. 413 413 ///- finite number: the upper bound 414 414 Value &upperBound() { return _ub; } -
lemon/maps.h
r1531 r1536 228 228 ///Its \c Value is inherited from \c M. 229 229 /// 230 ///Actually,231 ///\code232 /// ConvertMap<X> sh(x,v);233 ///\endcode234 ///it is equivalent with235 ///\code236 /// ConstMap<X::Key, X::Value> c_tmp(v);237 /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);238 ///\endcode239 230 ///\bug wrong documentation 240 231 template<class M, class T> … … 253 244 254 245 ///Constructor 255 ///\param _m is the undelying map 256 ///\param _v is the convert value 246 ///\param _m is the underlying map 257 247 ConvertMap(const M &_m) : m(_m) {}; 258 248 … … 260 250 /// 261 251 /// The subscript operator. 262 /// \param edge The edge252 /// \param k The key 263 253 /// \return The target of the edge 264 254 Value operator[](Key k) const {return m[k];} … … 298 288 299 289 ///Constructor 300 301 ///\e302 ///303 290 AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 304 291 Value operator[](Key k) const {return m1[k]+m2[k];} … … 387 374 388 375 ///Constructor 389 390 ///\e391 ///392 376 SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 393 377 Value operator[](Key k) const {return m1[k]-m2[k];} … … 427 411 428 412 ///Constructor 429 430 ///\e431 ///432 413 MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 433 414 Value operator[](Key k) const {return m1[k]*m2[k];} … … 513 494 514 495 ///Constructor 515 516 ///\e517 ///518 496 DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 519 497 Value operator[](Key k) const {return m1[k]/m2[k];} … … 561 539 562 540 ///Constructor 563 564 ///\e565 ///566 541 ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 567 542 Value operator[](Key k) const {return m1[m2[k]];} … … 616 591 617 592 ///Constructor 618 619 ///\e620 ///621 593 CombineMap(const M1 &_m1,const M2 &_m2,const F &_f) 622 594 : m1(_m1), m2(_m2), f(_f) {}; … … 667 639 668 640 ///Constructor 669 670 ///\e671 ///672 641 NegMap(const M &_m) : m(_m) {}; 673 642 Value operator[](Key k) const {return -m[k];} … … 721 690 722 691 ///Constructor 723 724 ///\e725 ///726 692 AbsMap(const M &_m) : m(_m) {}; 727 693 Value operator[](Key k) const {Value tmp=m[k]; return tmp>=0?tmp:-tmp;} … … 764 730 765 731 ///Constructor 766 767 ///\e768 ///769 732 FunctorMap(const F &_f) : f(_f) {}; 770 733 Value operator[](Key k) const {return f(k);}
Note: See TracChangeset
for help on using the changeset viewer.