8 #ifndef IMPBASE_INDEX_H
9 #define IMPBASE_INDEX_H
11 #include <IMP/base/base_config.h>
17 IMPBASE_BEGIN_NAMESPACE
27 explicit Index(
int i): i_(i){}
45 inline unsigned int get_as_unsigned_int(
Index<Tag> i) {
49 inline Index<Tag> get_invalid_index() {
50 return Index<Tag>(-1);
55 template <
class Tag,
class T>
63 return P::operator[](get_as_unsigned_int(i)));
66 template <
class Tag,
class Container,
class T>
68 const T&default_value=T()) {
69 if (v.size() <=get_as_unsigned_int(i)) {
70 v.resize(get_as_unsigned_int(i)+1, default_value);