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() {
54 Array(SwigData x, SwigData y) {
60 Array(SwigData x, SwigData y, SwigData z) {
67 Array(SwigData x0, SwigData x1, SwigData x2, SwigData x3) {
75 SwigData
get(
unsigned int i)
const {
return d_[i]; }
77 for (
unsigned int i = 0; i < D; ++i) {
78 boost::hash_combine(seed, d_[i]);
82 const Data operator[](
unsigned int i)
const {
86 Data& operator[](
unsigned int i) {
91 void set_item(
unsigned int i, SwigData v)
const {
98 SwigData __getitem__(
unsigned int i)
const {
100 return operator[](i);
102 unsigned int __len__()
const {
return D; }
105 unsigned int size()
const {
return D; }
107 std::string get_name()
const {
108 std::ostringstream oss;
110 for (
unsigned int i = 0; i < D; ++i) {
120 typedef typename Storage::iterator iterator;
121 iterator begin() {
return d_.begin(); }
122 iterator end() {
return d_.end(); }
123 typedef typename Storage::const_iterator const_iterator;
124 const_iterator begin()
const {
return d_.begin(); }
125 const_iterator end()
const {
return d_.end(); }
128 IMPBASE_END_NAMESPACE
An exception for a request for an invalid member of a container.
#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)
Base for a simple primitive-like type.
#define IMP_COMPARISONS(Name)
Implement comparison in a class using a compare function.
A class to store an fixed array of same-typed values.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
Various general useful macros for IMP.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Exception definitions and assertions.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
Various general useful macros for IMP.