1 #include "merge_count.h"
3 #include <unordered_set>
7 Count merge_count(const Count& c0, const Count& c1)
11 c.set_white(c0.white() + c1.white());
12 c.set_draw(c0.draw() + c1.draw());
13 c.set_black(c0.black() + c1.black());
14 c.set_computer(c0.computer() + c1.computer());
15 c.set_sum_white_elo(c0.sum_white_elo() + c1.sum_white_elo());
16 c.set_sum_black_elo(c0.sum_black_elo() + c1.sum_black_elo());
17 c.set_num_elo(c0.num_elo() + c1.num_elo());
18 if (c0.first_timestamp() <= c1.first_timestamp()) {
19 c.set_opening_num(c0.opening_num());
20 if (c0.has_first_timestamp()) {
21 c.set_first_timestamp(c0.first_timestamp());
23 c.set_pgn_file_num(c0.pgn_file_num());
24 c.set_pgn_start_position(c0.pgn_start_position());
26 c.set_opening_num(c1.opening_num());
27 if (c1.has_first_timestamp()) {
28 c.set_first_timestamp(c1.first_timestamp());
30 c.set_pgn_file_num(c1.pgn_file_num());
31 c.set_pgn_start_position(c1.pgn_start_position());
34 // Merge the moves, with deduplication.
35 unordered_set<string> moves;
36 for (int i = 0; i < c0.move_size(); ++i) {
37 moves.insert(c0.move(i));
38 c.add_move(c0.move(i));
40 for (int i = 0; i < c1.move_size(); ++i) {
41 if (!moves.count(c1.move(i))) {
42 c.add_move(c1.move(i));