Skip to content

Commit

Permalink
modernizing, using c++17 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Aug 28, 2024
1 parent dc7aa41 commit ff6ac0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/IGExperiment.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ namespace Timbl {
ostream& operator<< ( ostream& os,
const fileDoubleIndex& fmi ){
os << "[";
for ( const auto& it : fmi ){
os << it.first << " " << it.second << endl;
for ( const auto& [fv,index] : fmi ){
os << fv << " " << index << endl;
}
os << "]";
return os;
Expand Down
20 changes: 5 additions & 15 deletions src/Targets.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ namespace Timbl {

ClassDistribution *ClassDistribution::to_VD_Copy( ) const {
ClassDistribution *res = new ClassDistribution();
for ( const auto& d : distribution ){
size_t key = d.first;
const Vfield *vdf = d.second;
for ( const auto& [key,vdf] : distribution ){
res->distribution[key] = new Vfield( vdf->Value(),
vdf->Freq(),
vdf->Freq() );
Expand All @@ -260,9 +258,7 @@ namespace Timbl {

WClassDistribution *ClassDistribution::to_WVD_Copy() const {
WClassDistribution *res = new WClassDistribution();
for ( const auto& d : distribution ){
size_t key = d.first;
const Vfield *vdf = d.second;
for ( const auto& [key,vdf] : distribution ){
res->distribution[key] = new Vfield( vdf->Value(),
vdf->Freq(),
vdf->Freq() );
Expand All @@ -273,9 +269,7 @@ namespace Timbl {

WClassDistribution *WClassDistribution::to_WVD_Copy( ) const {
WClassDistribution *result = new WClassDistribution();
for ( const auto& d : distribution ){
size_t key = d.first;
const Vfield *vdf = d.second;
for ( const auto& [key,vdf] : distribution ){
result->distribution[key] = new Vfield( vdf->Value(),
vdf->Freq(),
vdf->Weight() );
Expand Down Expand Up @@ -433,9 +427,7 @@ namespace Timbl {
}

void ClassDistribution::Merge( const ClassDistribution& VD ){
for ( const auto& it : VD.distribution ){
size_t key = it.first;
const Vfield *vd = it.second;
for ( const auto& [key,vd] : VD.distribution ){
if ( distribution.find(key) != distribution.end() ){
// the key is already present, increment the frequency
distribution[key]->AddFreq( vd->Freq() );
Expand All @@ -453,9 +445,7 @@ namespace Timbl {

void WClassDistribution::MergeW( const ClassDistribution& VD,
double Weight ){
for ( const auto& it : VD.distribution ){
size_t key = it.first;
const Vfield *vd = it.second;
for ( const auto& [key,vd] : VD.distribution ){
if ( distribution.find(key) != distribution.end() ){
distribution[key]->SetWeight( distribution[key]->Weight() + vd->Weight() *Weight );
}
Expand Down
4 changes: 2 additions & 2 deletions src/TimblExperiment.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ namespace Timbl {
}

ostream& operator<< ( ostream& os, const fileIndex& fi ){
for ( const auto& it : fi ){
for ( const auto& [fv,index] : fi ){
os << "<";
os << it.first << "," << it.second;
os << fv << "," << index;
os << ">";
}
return os;
Expand Down

0 comments on commit ff6ac0d

Please sign in to comment.