2 #ifndef vbl_array_3d_hxx_ 3 #define vbl_array_3d_hxx_ 29 if ((n1 * n2 * n3)==0) {
35 element_ =
new T** [n1];
39 element_[0] =
new T* [n1 * n2];
40 for (
size_type row1_index = 0; row1_index < n1; row1_index++)
41 element_ [row1_index] = element_[0] + n2 * row1_index;
44 T* array_ptr =
new T [n1*n2*n3];
47 for (
size_type row1_index = 0; row1_index < n1; row1_index++)
48 for (
size_type row2_index = 0; row2_index < n2; row2_index++) {
49 element_ [row1_index][row2_index] = array_ptr;
59 delete [] element_ [0][0];
62 delete [] element_ [0];
72 if (n1 == row1_count_ && n2 == row2_count_ && n3 == row3_count_)
75 construct(n1, n2, n3);
84 for (
size_type row1_index = 0; row1_index < row1_count_; row1_index++)
85 for (
size_type row2_index = 0; row2_index < row2_count_; row2_index++)
86 for (
size_type row3_index = 0; row3_index < row3_count_; row3_index++)
87 element_ [row1_index][row2_index][row3_index] = *p++;
94 for (
size_type row1_index = 0; row1_index < row1_count_; row1_index++)
95 for (
size_type row2_index = 0; row2_index < row2_count_; row2_index++)
96 for (
size_type row3_index = 0; row3_index < row3_count_; row3_index++)
97 *p++ = element_ [row1_index][row2_index][row3_index];
104 size_type n = row1_count_ * row2_count_ * row3_count_;
114 # include <vcl_msvc_warnings.h> 121 os <<
"vbl_array_3d [";
123 os << std::endl <<
" <" << i << '>
'; 124 for (size_type j=0; j<A.get_row2_count(); ++j) { 125 os << std::endl << " "; 126 for (size_type k=0; k<A.get_row3_count(); ++k) { 127 os << ' ' << A(i,j,k); 131 os << "\n ]" << std::endl; 136 std::istream & operator>>(std::istream& is, vbl_array_3d<T>& A) 138 typedef typename vbl_array_3d<T>::size_type size_type; 139 for (size_type i=0; i<A.get_row1_count(); ++i) 140 for (size_type j=0; j<A.get_row2_count(); ++j) 141 for (size_type k=0; k<A.get_row3_count(); ++k) 146 //-------------------------------------------------------------------------------- 148 #undef VBL_ARRAY_3D_INSTANTIATE 149 #define VBL_ARRAY_3D_INSTANTIATE(T) template class vbl_array_3d<T > 151 #undef VBL_ARRAY_3D_IO_INSTANTIATE 152 #define VBL_ARRAY_3D_IO_INSTANTIATE(T) \ 153 template std::ostream & operator<<(std::ostream &,vbl_array_3d<T > const &); \ 154 template std::istream & operator>>(std::istream &,vbl_array_3d<T > &) 156 #endif // vbl_array_3d_hxx_ void resize(size_type n1, size_type n2, size_type n3)
std::ostream & operator<<(std::ostream &os, vbl_array_3d< T > const &A)
void set(T const *array)
Fill from static array of Ts.
Contains class for templated 3d array.
Templated 3-dimensional array.
void fill(T const &value)
Fill with constant.
void construct(size_type, size_type, size_type)
Constructor utility.
size_type get_row1_count() const
void get(T *array) const
Get into array.