diff --git a/modules/algebra/src/Triangle3D.cpp b/modules/algebra/src/Triangle3D.cpp index ea24e2b645..ae07aaa5aa 100644 --- a/modules/algebra/src/Triangle3D.cpp +++ b/modules/algebra/src/Triangle3D.cpp @@ -56,11 +56,11 @@ Triangle3D get_largest_triangle(const Vector3Ds &points) { } algebra::Segment3D seg(triple[0], triple[1]); max_dist = 0; - for (unsigned int i = 0; i < points.size(); i++) { - double dist = algebra::get_distance(seg, points[i]); + for (const auto &point : points) { + double dist = algebra::get_distance(seg, point); if (dist > max_dist) { max_dist = dist; - triple[2] = points[i]; + triple[2] = point; } } return Triangle3D(triple[0], triple[1], triple[2]); diff --git a/modules/atom/src/DopePairScore.cpp b/modules/atom/src/DopePairScore.cpp index 1ebc793f06..3f95f9bab9 100644 --- a/modules/atom/src/DopePairScore.cpp +++ b/modules/atom/src/DopePairScore.cpp @@ -44,8 +44,8 @@ void add_dope_score_data(Atom atom) { void add_dope_score_data(Hierarchy h) { Hierarchies atoms = get_by_type(h, ATOM_TYPE); - for (unsigned int i = 0; i < atoms.size(); ++i) { - add_dope_score_data(Atom(atoms[i])); + for (const auto &atom : atoms) { + add_dope_score_data(Atom(atom)); } } diff --git a/modules/core/src/FixedRefiner.cpp b/modules/core/src/FixedRefiner.cpp index 544755f126..df256026e2 100644 --- a/modules/core/src/FixedRefiner.cpp +++ b/modules/core/src/FixedRefiner.cpp @@ -17,10 +17,10 @@ FixedRefiner::FixedRefiner(const ParticlesTemp &ps) IMP_LOG_VERBOSE("Created fixed particle refiner with " << ps.size() << " particles" << std::endl); m_ = ps[0]->get_model(); - for(unsigned int i = 0; i < ps.size(); i++){ - IMP_USAGE_CHECK(m_ == ps[i]->get_model(), + for (const auto &p : ps) { + IMP_USAGE_CHECK(m_ == p->get_model(), "refiner assumes all particles are from the same model"); - pis_.push_back(ps[i]->get_index()); + pis_.push_back(p->get_index()); } } @@ -34,8 +34,8 @@ const ParticlesTemp FixedRefiner::get_refined(Particle *) const { ParticlesTemp ps; - for(unsigned int i=0; i < pis_.size(); i++){ - ps.push_back(m_->get_particle(pis_[i])); + for (const auto &pi : pis_) { + ps.push_back(m_->get_particle(pi)); } return ps; } diff --git a/modules/misc/src/CommonEndpointPairFilter.cpp b/modules/misc/src/CommonEndpointPairFilter.cpp index f2f41497ff..07f0a3a555 100644 --- a/modules/misc/src/CommonEndpointPairFilter.cpp +++ b/modules/misc/src/CommonEndpointPairFilter.cpp @@ -31,9 +31,9 @@ int CommonEndpointPairFilter::get_value_index( ModelObjectsTemp CommonEndpointPairFilter::do_get_inputs( Model *m, const ParticleIndexes &pis) const { ModelObjectsTemp ret = IMP::get_particles(m, pis); - for (unsigned int i = 0; i < pis.size(); ++i) { - if (IMP::atom::Bond::get_is_setup(m, pis[i])) { - IMP::atom::Bond b(m, pis[i]); + for (auto pi : pis) { + if (IMP::atom::Bond::get_is_setup(m, pi)) { + IMP::atom::Bond b(m, pi); ret.push_back(b.get_bonded(0)); ret.push_back(b.get_bonded(1)); } diff --git a/modules/saxs/bin/compute_vr.cpp b/modules/saxs/bin/compute_vr.cpp index 46ce384bf2..c20b01caef 100644 --- a/modules/saxs/bin/compute_vr.cpp +++ b/modules/saxs/bin/compute_vr.cpp @@ -60,22 +60,22 @@ int main(int argc, char **argv) { if (vm.count("offset")) use_offset = true; IMP::saxs::Profiles exp_profiles; - for (unsigned int i = 0; i < files.size(); i++) { + for (const auto &file : files) { // check if file exists - std::ifstream in_file(files[i].c_str()); + std::ifstream in_file(file.c_str()); if (!in_file) { - std::cerr << "Can't open file " << files[i] << std::endl; + std::cerr << "Can't open file " << file << std::endl; exit(1); } - IMP_NEW(IMP::saxs::Profile, profile, (files[i])); + IMP_NEW(IMP::saxs::Profile, profile, (file)); if (profile->size() == 0) { - std::cerr << "can't parse input file " << files[i] << std::endl; + std::cerr << "can't parse input file " << file << std::endl; return 1; } else { - dat_files.push_back(files[i]); + dat_files.push_back(file); exp_profiles.push_back(profile); - std::cout << "Profile read from file " << files[i] + std::cout << "Profile read from file " << file << " size = " << profile->size() << std::endl; } } diff --git a/modules/saxs/src/utility.cpp b/modules/saxs/src/utility.cpp index d52a99e4dc..31cb195961 100644 --- a/modules/saxs/src/utility.cpp +++ b/modules/saxs/src/utility.cpp @@ -25,9 +25,9 @@ Profile* compute_profile(Particles particles, double min_q, double average_radius = 0.0; if (hydration_layer) { // add radius - for (unsigned int i = 0; i < particles.size(); i++) { - double radius = ft->get_radius(particles[i], ff_type); - core::XYZR::setup_particle(particles[i], radius); + for (auto &particle : particles) { + double radius = ft->get_radius(particle, ff_type); + core::XYZR::setup_particle(particle, radius); average_radius += radius; } surface_area = s.get_solvent_accessibility(core::XYZRs(particles)); @@ -121,28 +121,28 @@ void read_files(Model *m, const std::vector& files, bool heavy_atoms_only, int multi_model_pdb, bool explicit_water, float max_q, int units) { - for (unsigned int i = 0; i < files.size(); i++) { + for (const auto &file : files) { // check if file exists - std::ifstream in_file(files[i].c_str()); + std::ifstream in_file(file.c_str()); if (!in_file) { - IMP_WARN("Can't open file " << files[i] << std::endl); + IMP_WARN("Can't open file " << file << std::endl); return; } // 1. try as pdb or mmcif try { - read_pdb(m, files[i], pdb_file_names, particles_vec, residue_level, + read_pdb(m, file, pdb_file_names, particles_vec, residue_level, heavy_atoms_only, multi_model_pdb, explicit_water); } catch (const IMP::ValueException &e) { // not a pdb file // 2. try as a dat profile file - IMP_NEW(Profile, profile, (files[i], false, max_q, units)); + IMP_NEW(Profile, profile, (file, false, max_q, units)); if (profile->size() == 0) { - IMP_WARN("can't parse input file " << files[i] << std::endl); + IMP_WARN("can't parse input file " << file << std::endl); return; } else { - dat_files.push_back(files[i]); + dat_files.push_back(file); exp_profiles.push_back(profile); - IMP_LOG_TERSE("Profile read from file " << files[i] + IMP_LOG_TERSE("Profile read from file " << file << " size = " << profile->size() << std::endl); } }