wfmath 1.0.3
A math library for the Worldforge system.
wrapped_array.h
1
2
3// Copright (C) 1999
4// $Revision$
5// $Date$
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA,
20// or download the License terms from prep.ai.mit.edu/pub/gnu/COPYING-2.0.
21//
22// Contact:
23// --------
24// Bernd Gaertner
25// Institut f. Informatik
26// ETH Zuerich
27// ETH-Zentrum
28// CH-8092 Zuerich, Switzerland
29// http://www.inf.ethz.ch/personal/gaertner
30//
31
32#ifndef WFMATH_WRAPPED_ARRAY_H
33#define WFMATH_WRAPPED_ARRAY_H
34
35namespace WFMath { namespace _miniball {
36
37 template <int d>
39 private:
40 double coord [d]{};
41
42 public:
43 // default
44 Wrapped_array() = default;
45
46 // copy from Wrapped_array
47 Wrapped_array (const Wrapped_array& p) = default;
48
49 // copy from double*
50 Wrapped_array (const double* p)
51 {
52 for (int i=0; i<d; ++i)
53 coord[i] = p[i];
54 }
55
56 // assignment
57 Wrapped_array& operator = (const Wrapped_array& p) = default;
58
59 // coordinate access
60 double& operator [] (int i)
61 {
62 return coord[i];
63 }
64 const double& operator [] (int i) const
65 {
66 return coord[i];
67 }
68 const double* begin() const
69 {
70 return coord;
71 }
72 const double* end() const
73 {
74 return coord+d;
75 }
76 };
77
78}} // namespace WFMath::_miniball
79
80#endif // WFMATH_WRAPPED_ARRAY_H
Generic library namespace.
Definition: shape.h:41