9 #ifndef IMPBASE_ARRAY_H
10 #define IMPBASE_ARRAY_H
12 #include <IMP/base/base_config.h>
18 #include <boost/array.hpp>
20 IMPBASE_BEGIN_NAMESPACE
32 template <
unsigned int D,
class Data,
class SwigData = Data>
34 typedef boost::array<Data, D> Storage;
37 for (
unsigned int i = 0; i < D; ++i) {
40 else if (d_[i] > o[i])
48 typedef SwigData value_type;
50 unsigned int get_dimension() {
return D; }
53 Array(SwigData x, SwigData y) {
59 Array(SwigData x, SwigData y, SwigData z) {
66 Array(SwigData x0, SwigData x1, SwigData x2, SwigData x3) {
74 SwigData
get(
unsigned int i)
const {
return d_[i]; }
76 for (
unsigned int i = 0; i < D; ++i) {
77 boost::hash_combine(seed, d_[i]);
81 const Data operator[](
unsigned int i)
const {
85 Data& operator[](
unsigned int i) {
90 void set_item(
unsigned int i, SwigData v)
const {
97 SwigData __getitem__(
unsigned int i)
const {
101 unsigned int __len__()
const {
return D; }
104 unsigned int size()
const {
return D; }
106 std::string get_name()
const {
107 std::ostringstream oss;
109 for (
unsigned int i = 0; i < D; ++i) {
119 typedef typename Storage::iterator iterator;
120 iterator begin() {
return d_.begin(); }
121 iterator end() {
return d_.end(); }
122 typedef typename Storage::const_iterator const_iterator;
123 const_iterator begin()
const {
return d_.begin(); }
124 const_iterator end()
const {
return d_.end(); }
127 IMPBASE_END_NAMESPACE
An exception for a request for an invalid member of a container.
Various general useful macros for IMP.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Various general useful macros for IMP.
#define IMP_HASHABLE_INLINE(name, hashret)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
A class to store an fixed array of same-typed values.
#define IMP_COMPARISONS(Name)
Implement comparison in a class using a compare function.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Various general useful macros for IMP.
Exception definitions and assertions.