saebyn / munkres-cpp

Kuhn-Munkres (Hungarian) Algorithm in C++
http://saebyn.info/2007/05/22/munkres-code-v2/
GNU General Public License v2.0
205 stars 79 forks source link

C++11 migration #8

Closed Gluttton closed 10 years ago

Gluttton commented 10 years ago

Except a lot of benefits it's allow to create tests in easiest way. For instance using std::initializer_list: instead of this:

    // Arrange.
    // - + -
    // + - -
    // - - +
    Matrix <double> etalon_matrix (3, 3);
    etalon_matrix (0, 0) = -1.0;
    etalon_matrix (0, 1) = 0.0;
    etalon_matrix (0, 2) = -1.0;
    etalon_matrix (1, 0) = 0.0;
    etalon_matrix (1, 1) = -1.0;
    etalon_matrix (1, 2) = -1.0;
    etalon_matrix (2, 0) = -1.0;
    etalon_matrix (2, 1) = -1.0;
    etalon_matrix (2, 2) = 0.0;
    // 1 0 1
    // 0 1 1
    // 1 1 0
    Matrix <double> test_matrix (3, 3);
    test_matrix (0, 0) = 1.0;
    test_matrix (0, 1) = 0.0;
    test_matrix (0, 2) = 1.0;
    test_matrix (1, 0) = 0.0;
    test_matrix (1, 1) = 1.0;
    test_matrix (1, 2) = 1.0;
    test_matrix (2, 0) = 1.0;
    test_matrix (2, 1) = 1.0;
    test_matrix (2, 2) = 0.0;

write something like this:

    // Arrange.
    Matrix <double> etalon_matrix ({
        {-1.0,  0.0, -1.0},
        { 0.0, -1.0, -1.0},
        {-1.0, -1.0,  0.0}
    });
    Matrix <double> test_matrix ({
        { 1.0,  0.0,  1.0},
        { 0.0,  1.0,  1.0},
        { 1.0,  1.0,  0.0}
    });

Looks like self documented.

saebyn commented 10 years ago

I added this in da95d6bbeb690e31188ff5c3ee41e2ca14c5a277