MRPT  1.9.9
List of all members | Public Member Functions | Public Attributes
CCoinDistribution Class Reference

Detailed Description

This is a example of problem resolution using the CAStarAlgorithm template.

Although this problem is better solved with dynamic programming, it illustrates perfectly how to inherit from that template in order to solve a problem.

Let's assume a currency composed of coins whose values are 2, 7, 8 and 19. The problem consists of finding a minimal set of these coins whose total value equals a given amount.

Definition at line 32 of file vision_stereo_rectify/test.cpp.

Public Member Functions

 CCoinDistribution ()
 
size_t money () const
 Auxiliary function to calculate the amount of money. More...
 
bool operator== (const CCoinDistribution &mon) const
 Implementing the == operator is mandatory, because it allows the A* algorithm to reject repeated solutions. More...
 

Public Attributes

size_t coins2 {0}
 
size_t coins7 {0}
 
size_t coins8 {0}
 
size_t coins19 {0}
 

Constructor & Destructor Documentation

◆ CCoinDistribution()

CCoinDistribution::CCoinDistribution ( )
inline

Definition at line 39 of file vision_stereo_rectify/test.cpp.

Member Function Documentation

◆ money()

size_t CCoinDistribution::money ( ) const
inline

Auxiliary function to calculate the amount of money.

Not strictly necessary, but handy.

Definition at line 44 of file vision_stereo_rectify/test.cpp.

◆ operator==()

bool CCoinDistribution::operator== ( const CCoinDistribution mon) const
inline

Implementing the == operator is mandatory, because it allows the A* algorithm to reject repeated solutions.

Actually, the template should not compile if this operator is not present.

Definition at line 54 of file vision_stereo_rectify/test.cpp.

Member Data Documentation

◆ coins19

size_t CCoinDistribution::coins19 {0}

Definition at line 38 of file vision_stereo_rectify/test.cpp.

◆ coins2

size_t CCoinDistribution::coins2 {0}

Definition at line 35 of file vision_stereo_rectify/test.cpp.

◆ coins7

size_t CCoinDistribution::coins7 {0}

Definition at line 36 of file vision_stereo_rectify/test.cpp.

◆ coins8

size_t CCoinDistribution::coins8 {0}

Definition at line 37 of file vision_stereo_rectify/test.cpp.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020