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
33 template <
unsigned int D,
class Data,
class SwigData=Data>
37 typedef boost::array<Data, D> Storage;
40 for (
unsigned int i=0;i<D; ++i) {
41 if (d_[i] < o[i])
return -1;
42 else if (d_[i] > o[i])
return 1;
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 {
78 for (
unsigned int i=0; i< D; ++i) {
79 boost::hash_combine(seed,
85 const Data operator[](
unsigned int i)
const {
89 Data& operator[](
unsigned int i) {
94 void set_item(
unsigned int i, SwigData v)
const {
101 SwigData __getitem__(
unsigned int i)
const {
102 if (i >= D)
IMP_THROW(
"Out of bound " << i <<
" vs " << D,
104 return operator[](i);
106 unsigned int __len__()
const {
return D;}
109 unsigned int size()
const {
113 std::string get_name()
const {
114 std::ostringstream oss;
116 for (
unsigned int i=0; i< D; ++i) {
128 typedef typename Storage::iterator iterator;
135 typedef typename Storage::const_iterator const_iterator;
136 const_iterator begin()
const {
139 const_iterator end()
const {
145 IMPBASE_END_NAMESPACE