IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
NeighborsTable.h
Go to the documentation of this file.
1/**
2 * \file IMP/core/NeighborsTable.h
3 * \brief
4 *
5 * Copyright 2007-2022 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPCORE_NEIGHBORS_TABLE_H
10#define IMPCORE_NEIGHBORS_TABLE_H
11
12#include <IMP/core/core_config.h>
14#include <IMP/ScoreState.h>
15#include <IMP/Pointer.h>
16#include <boost/unordered_map.hpp>
17
18IMPCORE_BEGIN_NAMESPACE
19
20/** Maintain a table that can be used to look up the neighbors
21 of particles. That is, you can efficiently find all
22 particles that are within a certain distance of a passed one.
23
24 As with the container::ClosePairContainer, there may be some
25 neighbors returned that are not close neighbors, but all close
26 neighbors will be returned.
27*/
28class IMPCOREEXPORT NeighborsTable : public ScoreState {
30 std::size_t input_version_;
31 boost::unordered_map<ParticleIndex, ParticleIndexes> data_;
32
33 protected:
34 virtual ModelObjectsTemp do_get_inputs() const override {
35 return ModelObjectsTemp(1, input_);
36 }
37 virtual ModelObjectsTemp do_get_outputs() const override {
38 return ModelObjectsTemp();
39 }
40 virtual void do_before_evaluate() override;
41 virtual void do_after_evaluate(DerivativeAccumulator *) override {}
42
43 public:
45 std::string name = "CloseNeighborsTable%1%");
46 /** Return all ParticleIndexes that are within the distance threshold
47 of this one (plus some that are aren't, for efficiency). */
49 set_was_used(true);
50 return data_.find(pi)->second;
51 }
52 IMP_OBJECT_METHODS(NeighborsTable);
53};
54
55IMPCORE_END_NAMESPACE
56
57#endif /* IMPCORE_NEIGHBORS_TABLE_H */
A nullptr-initialized pointer to an IMP Object.
Shared score state.
A container for Singletons.
Class for adding derivatives from restraints to the model.
void set_was_used(bool tf) const
A shared container for Pairs.
virtual ModelObjectsTemp do_get_outputs() const override
const ParticleIndexes & get_neighbors(ParticleIndex pi) const
virtual void do_before_evaluate() override
Update the state given the current state of the model.
virtual ModelObjectsTemp do_get_inputs() const override
virtual void do_after_evaluate(DerivativeAccumulator *) override
Do any necessary updates after the model score is calculated.
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
A smart pointer to a ref-counted Object that is a class member.
Definition Pointer.h:144