Skip to content

Commit

Permalink
Fix training tools for legacy engine (issue #3925) (#3970)
Browse files Browse the repository at this point in the history
Fixes: cac116d ("Replace more PointerVector by std::vector [...]")
Signed-off-by: Stefan Weil <sw@weilnetz.de>

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil authored Nov 30, 2022
1 parent 7221973 commit af13124
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/training/common/trainingsampleset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,22 +539,14 @@ void TrainingSampleSet::KillSample(TrainingSample *sample) {
// Deletes all samples with zero features marked by KillSample.
void TrainingSampleSet::DeleteDeadSamples() {
using namespace std::placeholders; // for _1
auto old_it = samples_.begin();
for (; old_it < samples_.end(); ++old_it) {
if (*old_it == nullptr || (*old_it)->class_id() < 0) {
break;
}
}
auto new_it = old_it;
for (; old_it < samples_.end(); ++old_it) {
if (*old_it == nullptr || (*old_it)->class_id() < 0) {
delete *old_it;
for (auto &&it = samples_.begin(); it < samples_.end();) {
if (*it == nullptr || (*it)->class_id() < 0) {
samples_.erase(it);
delete *it;
} else {
*new_it = *old_it;
++new_it;
++it;
}
}
samples_.resize(new_it - samples_.begin() + 1);
num_raw_samples_ = samples_.size();
// Samples must be re-organized now we have deleted a few.
}
Expand Down

0 comments on commit af13124

Please sign in to comment.