/** * \file AllPairContainer.cpp \brief A list of ParticlePairs. * * This file is generated by a script (core/tools/make-container). * Do not edit directly. * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #include "IMP/container/AllPairContainer.h" #include #include #include #include #include IMPCONTAINER_BEGIN_NAMESPACE AllPairContainer::AllPairContainer(SingletonContainer *c, bool): c_(c){ a_=1; b_=0; i_=0; } AllPairContainer::AllPairContainer(SingletonContainer *c): c_(c), deps_(new DependenciesScoreState(this), c->get_model()){ a_=1; b_=0; i_=0; } PairContainerPair AllPairContainer::get_added_and_removed_containers() const { IMP_NEW(IMP::core::internal::DifferenceSingletonContainer, old, (c_, c_->get_removed_container())); IMP::Pointer removed = PairContainerSet::create_untracked_container(); { IMP_NEW(AllPairContainer, all, (c_->get_removed_container(), false)); removed->add_pair_container(all); IMP_NEW(AllBipartitePairContainer, leftr, (c_->get_removed_container(), old, false)); removed->add_pair_container(leftr); } IMP::Pointer added = PairContainerSet::create_untracked_container(); { IMP_NEW(AllPairContainer,all, (c_->get_added_container(), false)); added->add_pair_container(all); IMP_NEW(AllBipartitePairContainer,leftr, (c_->get_added_container(), old, false)); added->add_pair_container(leftr); } return PairContainerPair(added, removed); } unsigned int AllPairContainer::get_number_of_particle_pairs() const { unsigned int n= c_->get_number_of_particles(); return n*(n-1)/2; } //! ParticlePair AllPairContainer::get_particle_pair(unsigned int i) const { IMP_INTERNAL_CHECK(i < get_number_of_particle_pairs(), "Invalid pair requested"); // dumb method, just increase the current pair until we get to the desired one if (static_cast(i) < i_) { a_=1; b_=0; i_=0; } while (i_ < static_cast(i)) { ++b_; if (b_==a_) { ++a_; b_=0; } ++i_; } return ParticlePair(c_->get_particle(a_), c_->get_particle(b_)); } bool AllPairContainer::get_contains_particle_pair(const ParticlePair &p) const { return c_->get_contains_particle(p[0]) && c_->get_contains_particle(p[1]); } void AllPairContainer::do_show(std::ostream &out) const { IMP_CHECK_OBJECT(this); out << "container " << *c_ << std::endl; } ParticlesTemp AllPairContainer::get_contained_particles() const { return c_->get_contained_particles(); } bool AllPairContainer::get_contained_particles_changed() const { return c_->get_contained_particles_changed(); } IMPCONTAINER_END_NAMESPACE