9 #ifndef IMPKERNEL_INDEX_H
10 #define IMPKERNEL_INDEX_H
12 #include <IMP/kernel_config.h>
18 IMPKERNEL_BEGIN_NAMESPACE
29 explicit Index(
int i) : i_(i) {}
47 inline unsigned int get_as_unsigned_int(
Index<Tag> i) {
51 inline Index<Tag> get_invalid_index() {
52 return Index<Tag>(-1);
56 template <
class Tag,
class T>
61 IndexVector(
unsigned int sz,
const T &t = T()) :
P(sz, t) {}
64 return P::operator[](get_as_unsigned_int(i)));
67 template <
class Tag,
class Container,
class T>
69 if (v.size() <= get_as_unsigned_int(i)) {
70 v.resize(get_as_unsigned_int(i) + 1, default_value);
74 IMPKERNEL_END_NAMESPACE
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_HASHABLE_INLINE(name, hashret)
#define IMP_BRACKET(Value, Index, bounds_check_expr, expr)
Implement operator[] and at() for C++, and getitem for Python.
A more IMP-like version of the std::vector.
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
Macros to handle array indexing.
Base class for a simple primitive-like type.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Implements a vector tied to a particular index of type Index<Tag>.
A class for storing lists of IMP items.
Base class for a simple primitive-like type.
#define IMP_COMPARISONS_1(Name, field)
Implement comparison in a class using field as the variable to compare.
Abstract class for containers of particles.
Macros to help with objects that can be printed to a stream.