Cloudy
Spectral Synthesis Code for Astrophysics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
container_classes.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef CONTAINER_CLASSES_H_
5 #define CONTAINER_CLASSES_H_
6 
13 
14 // magic numbers to identify each memory layout
15 static const int32 MA_VERS[ML_TOP] = { 120070905, 220070803, 320071126 };
16 
17 #ifdef USE_C_TYPE
18 #define MEM_LAYOUT_VAL C_TYPE
19 #else
20 #define MEM_LAYOUT_VAL ARPA_TYPE
21 #endif
22 
25 template<class T, bool lgBC>
27 {
28  static const int p_nd = lgBC ? 3 : 1;
29  T* p_p[p_nd]; // p[0] current pointer, p[1] lower bound, p[2] upper bound
30 
31  T* p_index_checked ( const ptrdiff_t n ) const
32  {
33  T* t = p_p[0]+n;
34  if( lgBC )
35  {
36  if( t < p_p[1] || t >= p_p[2] )
37  OUT_OF_RANGE( "basic_pntr::p_index_checked()" );
38  }
39  return t;
40  }
41  void p_set_vals( T* p0, T* p1, T* p2 )
42  {
43  if( lgBC )
44  {
45  p_p[0] = p0; p_p[1] = p1; p_p[2] = p2;
46  }
47  else
48  p_p[0] = p0;
49  }
50 public:
51  typedef random_access_iterator_tag iterator_category;
52  typedef T value_type;
53  typedef T& reference;
54  typedef const T& const_reference;
55  typedef T* pointer;
56  typedef const T* const_pointer;
57  typedef size_t size_type;
58  typedef ptrdiff_t difference_type;
59 
60  // constructors
61  basic_pntr( T* p0, T* p1, T* p2 )
62  {
63  p_set_vals( p0, p1, p2 );
64  }
65  basic_pntr( T* p0 )
66  {
67  p_set_vals( p0, NULL, NULL );
68  }
70  {
71  p_set_vals( NULL, NULL, NULL );
72  }
73  basic_pntr& operator= ( const basic_pntr& ) = default;
74  basic_pntr( const basic_pntr& t ) = default;
75  // protected destructor (to prevent direct instantiation or destruction via basic_pntr*, see Alexandrescu p13)
76 protected:
78 public:
79  // pre-increment
81  {
82  ++p_p[0];
83  return *this;
84  }
85  // pre-decrement
87  {
88  --p_p[0];
89  return *this;
90  }
91  // define operators for += and -=, normal arithmetic is defined separately in
92  // the derived classes; it cannot be done here since they would require implicit
93  // conversion from basic_pntr -> pntr or const_pntr to work; this would also create
94  // an implicit and silent conversion from const_pntr -> pntr, which is illegal...
95  basic_pntr& operator+= ( const ptrdiff_t n ) { p_p[0] += n; return *this; }
96  basic_pntr& operator-= ( const ptrdiff_t n ) { p_p[0] -= n; return *this; }
97  // dereference
98  T& operator* () const
99  {
100  return *(p_index_checked(0));
101  }
102  T* operator-> () const
103  {
104  return p_index_checked(0);
105  }
106  T& operator[] ( const ptrdiff_t n ) const
107  {
108  return *(p_index_checked(n));
109  }
110  // finally, define the boolean operators...
111  bool operator== ( const basic_pntr& t ) const { return p_p[0] == t.p_p[0]; }
112  bool operator!= ( const basic_pntr& t ) const { return p_p[0] != t.p_p[0]; }
113  bool operator< ( const basic_pntr& t ) const { return p_p[0] < t.p_p[0]; }
114  bool operator<= ( const basic_pntr& t ) const { return p_p[0] <= t.p_p[0]; }
115  bool operator> ( const basic_pntr& t ) const { return p_p[0] > t.p_p[0]; }
116  bool operator>= ( const basic_pntr& t ) const { return p_p[0] >= t.p_p[0]; }
117 };
118 
120 template<class T, bool lgBC>
121 class pntr : public basic_pntr<T,lgBC>
122 {
123 public:
124  // constructors are not inherited, so define them again
125  pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {}
126  pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {}
127  pntr() {}
128  // the increment / decrement operators need to be recast...
129  // otherwise expressions like p = ++q would be illegal for iterators...
130  pntr& operator++ () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator++()); }
131  const pntr operator++ (int) { pntr t = *this; ++(*this); return t; }
132  pntr& operator-- () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator--()); }
133  const pntr operator-- (int) { pntr t = *this; --(*this); return t; }
134  // define p+n, p-n, p-q
135  const pntr operator+ ( const ptrdiff_t n ) const { pntr s = *this; s += n; return s; }
136  const pntr operator- ( const ptrdiff_t n ) const { pntr s = *this; s -= n; return s; }
137  ptrdiff_t operator- ( const pntr& t ) const { return &(*this[0]) - &t[0]; }
138 };
139 
140 // this defines n+p
141 template<class T, bool lgBC>
142 inline const pntr<T,lgBC> operator+ ( const ptrdiff_t n, const pntr<T,lgBC>& t )
143 {
144  pntr<T,lgBC> s = t;
145  s += n;
146  return s;
147 }
148 
150 template<class T, bool lgBC>
151 class const_pntr : public basic_pntr<T,lgBC>
152 {
153 public:
154  // constructors are not inherited, so define them again
155  const_pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {}
156  const_pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {}
158  // make sure we can assign a pntr to a const_pntr by creating an implicit conversion to const_pntr
159  const_pntr( const pntr<T,lgBC>& t ) : basic_pntr<T,lgBC>( t ) {}
160  // the increment / decrement operators need to be recast...
161  // otherwise expressions like *p++ = 1. would be legal for const_iterators...
163  const const_pntr operator++ (int) { const_pntr t = *this; ++(*this); return t; }
165  const const_pntr operator-- (int) { const_pntr t = *this; --(*this); return t; }
166  const_pntr& operator+= ( const ptrdiff_t n )
167  {
168  return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator+=(n));
169  }
170  const_pntr& operator-= ( const ptrdiff_t n )
171  {
172  return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator-=(n));
173  }
174  // the dereference operators need to be recast...
175  const T& operator* () const { return static_cast<const T&>(basic_pntr<T,lgBC>::operator*()); }
176  const T* operator-> () const { return static_cast<const T*>(basic_pntr<T,lgBC>::operator->()); }
177  const T& operator[] ( const ptrdiff_t n ) const
178  {
179  return static_cast<const T&>(basic_pntr<T,lgBC>::operator[](n));
180  }
181  // define p+n, p-n, p-q
182  const const_pntr operator+ ( const ptrdiff_t n ) const { const_pntr s = *this; s += n; return s; }
183  const const_pntr operator- ( const ptrdiff_t n ) const { const_pntr s = *this; s -= n; return s; }
184  ptrdiff_t operator- ( const const_pntr& t ) const { return &(*this[0]) - &t[0]; }
185 };
186 
187 // this defines n+p
188 template<class T, bool lgBC>
189 inline const const_pntr<T,lgBC> operator+ ( const ptrdiff_t n, const const_pntr<T,lgBC>& t )
190 {
191  const_pntr<T,lgBC> s = t;
192  s += n;
193  return s;
194 }
195 
197 struct tree_vec
198 {
199  typedef size_t size_type;
200 
203 
204 private:
205  void p_clear0()
206  {
207  if( d != NULL )
208  {
209  for( size_type i = 0; i < n; ++i )
210  d[i].clear();
211  delete[] d;
212  }
213  }
214  void p_clear1()
215  {
216  n = 0;
217  d = NULL;
218  }
219 
220 public:
222  {
223  p_clear1();
224  }
225  tree_vec(const tree_vec& m)
226  {
227  p_clear1();
228  *this = m;
229  }
231  {
232  p_clear0();
233  }
234  void clear()
235  {
236  p_clear0();
237  p_clear1();
238  }
239  const tree_vec& operator= (const tree_vec& m)
240  {
241  if( &m != this )
242  {
243  clear();
244  n = m.n;
245  if( m.d != NULL )
246  {
247  d = new tree_vec[n];
248  tree_vec *p = d;
249  const tree_vec *mp = m.d;
250  for( size_type i = 0; i < n; ++i )
251  *p++ = *mp++;
252  }
253  }
254  return *this;
255  }
256  tree_vec& getvec(const size_type i, const size_type index[])
257  {
258  if( i == 0 )
259  return *this;
260  else
261  return getvec(i-1,index).d[index[i-1]];
262  }
263  const tree_vec& getvec(const size_type i, const size_type index[]) const
264  {
265  if( i == 0 )
266  return *this;
267  else
268  return getvec(i-1,index).d[index[i-1]];
269  }
270 };
271 
274 template<int d,mem_layout ALLOC=MEM_LAYOUT_VAL>
276 {
277 public:
278  typedef size_t size_type;
279 
281 
286 
287 private:
288  void p_clear0()
289  {
290  v.clear();
291  }
292  void p_clear1()
293  {
294  size = 0;
295  for( int i=0; i < d; ++i )
296  {
297  s[i] = 0;
298  st[i] = 0;
299  nsl[i] = 0;
300  }
301  }
302 
303 public:
305  {
306  p_clear1();
307  }
309  {
310  p_clear1();
311  *this = m;
312  }
314  {
315  p_clear0();
316  }
317  void clear()
318  {
319  p_clear0();
320  p_clear1();
321  }
323  {
324  if( &m != this )
325  {
326  clear();
327  v = m.v;
328  size = m.size;
329  for( int i=0; i < d; ++i )
330  {
331  s[i] = m.s[i];
332  st[i] = m.st[i];
333  nsl[i] = m.nsl[i];
334  }
335  }
336  return *this;
337  }
338  bool lgInbounds(const size_type n, const size_type index[]) const
339  {
340  if( n != 0 )
341  return ( lgInbounds(n-1,index) && index[n-1] < v.getvec(n-1,index).n );
342  else
343  return true;
344  }
345  void reserve(const size_type n, const size_type index[])
346  {
347  ASSERT( n <= d && index[n-1] > 0 && lgInbounds( n-1, index ) );
348 
349  tree_vec& w = v.getvec( n-1, index );
350  if( d > n )
351  {
352  ASSERT( w.d == NULL );
353  w.d = new tree_vec[ index[n-1] ];
354  }
355  w.n = index[n-1];
356  s[n-1] = max(s[n-1],index[n-1]);
357  nsl[n-1] += index[n-1];
358  }
359  void reserve_recursive(const size_type n, size_type index[])
360  {
361  if( n == 0 )
362  {
363  reserve( n+1, index );
364  if( n+1 < d )
365  reserve_recursive( n+1, index );
366  }
367  else
368  {
369  size_type top = index[n-1];
370  for( size_type i=0; i < top; ++i )
371  {
372  index[n-1] = i;
373  reserve( n+1, index );
374  if( n+1 < d )
375  reserve_recursive( n+1, index );
376  }
377  index[n-1] = top;
378  }
379  }
380  void finalize(void)
381  {
382  static_assert( ALLOC == C_TYPE || ALLOC == ARPA_TYPE,
383  "Allocation type must be C_TYPE or ARPA_TYPE" );
384  if( ALLOC == ARPA_TYPE )
385  {
386  size_type n1[d], n2[d];
387  for( int dim=0; dim < d; ++dim )
388  n1[dim] = n2[dim] = 0L;
389  // sanity checks
390  p_setupArray( n1, n2, &v, 0 );
391  for( int dim=0; dim < d-1; ++dim )
392  ASSERT( n1[dim] == nsl[dim] && n2[dim] == nsl[dim+1] );
393  size = nsl[d-1];
394  }
395  else if( ALLOC == C_TYPE )
396  {
397  st[d-1] = s[d-1];
398  for( int i = d-2; i >= 0; --i )
399  st[i] = st[i+1]*s[i];
400  size = st[0];
401  }
402  else
403  {
404  TotalInsanity();
405  }
406  }
407 
408 private:
409  void p_setupArray( size_type n1[], size_type n2[], const tree_vec* w, size_type l )
410  {
411  for( size_type i=0; i < w->n; ++i )
412  {
413  n1[l]++;
414  // using int(l) is always safe and avoids warnings about the test
415  // 'l < d-2' being always false when d == 2 (e.g. with g++ 4.6.0)
416  if( int(l) < d-2 )
417  {
418  p_setupArray( n1, n2, &w->d[i], l+1 );
419  }
420  n2[l] += w->d[i].n;
421  }
422  }
423 };
424 
425 
426 //
529 //
530 
531 
532 // forward definitions
533 template<class T, int N, mem_layout ALLOC, bool lgBC> class n_pointer;
534 template<class T, int N, mem_layout ALLOC, bool lgBC> class const_n_pointer;
535 
536 template<class T, int N>
537 class n_pointer<T,N,ARPA_TYPE,false>
538 {
539  T* p_p;
540  const size_t* p_st;
541  const tree_vec* p_v;
542 public:
543  typedef n_pointer<T,N-1,ARPA_TYPE,false> value_type;
544  n_pointer(T* p, const size_t* st=NULL, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
545  const value_type operator[] (const size_t i) const
546  {
547  return value_type( *((T**)p_p+i) );
548  }
549 };
550 
551 template<class T, int N>
552 class n_pointer<T,N,C_TYPE,false>
553 {
554  T* p_p;
555  const size_t* p_st;
556  const tree_vec* p_v;
557 public:
558  typedef n_pointer<T,N-1,C_TYPE,false> value_type;
559  n_pointer(T* p, const size_t* st, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
560  const value_type operator[] (const size_t i) const
561  {
562  return value_type( p_p+i*p_st[0], p_st+1 );
563  }
564 };
565 
566 template<class T>
567 class n_pointer<T,1,ARPA_TYPE,false>
568 {
569  T* p_p;
570  const size_t* p_st;
571  const tree_vec* p_v;
572 public:
573  typedef T value_type;
574  n_pointer(T* p, const size_t* st=NULL, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
575  value_type& operator[] (const size_t i) const
576  {
577  return *(p_p + i);
578  }
579 };
580 
581 template<class T>
582 class n_pointer<T,1,C_TYPE,false>
583 {
584  T* p_p;
585  const size_t* p_st;
586  const tree_vec* p_v;
587 public:
588  typedef T value_type;
589  n_pointer(T* p, const size_t* st, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
590  value_type& operator[] (const size_t i) const
591  {
592  return *(p_p + i);
593  }
594 };
595 
596 template<class T, int N>
597 class n_pointer<T,N,ARPA_TYPE,true>
598 {
599  T* p_p;
600  const size_t* p_st;
601  const tree_vec* p_v;
602 public:
603  typedef n_pointer<T,N-1,ARPA_TYPE,true> value_type;
604  n_pointer(T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
605  const value_type operator[] (const size_t i) const
606  {
607  if( i >= p_v->n )
608  OUT_OF_RANGE( "n_pointer::operator[]" );
609  return value_type( *((T**)p_p+i), NULL, &p_v->d[i] );
610  }
611 };
612 
613 template<class T, int N>
614 class n_pointer<T,N,C_TYPE,true>
615 {
616  T* p_p;
617  const size_t* p_st;
618  const tree_vec* p_v;
619 public:
620  typedef n_pointer<T,N-1,C_TYPE,true> value_type;
621  n_pointer(T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
622  const value_type operator[] (const size_t i) const
623  {
624  if( i >= p_v->n )
625  OUT_OF_RANGE( "n_pointer::operator[]" );
626  return value_type( p_p+i*p_st[0], p_st+1, &p_v->d[i] );
627  }
628 };
629 
630 template<class T>
631 class n_pointer<T,1,ARPA_TYPE,true>
632 {
633  T* p_p;
634  const size_t* p_st;
635  const tree_vec* p_v;
636 public:
637  typedef T value_type;
638  n_pointer(T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
639  value_type& operator[] (const size_t i) const
640  {
641  if( i >= p_v->n )
642  OUT_OF_RANGE( "n_pointer::operator[]" );
643  return *(p_p + i);
644  }
645 };
646 
647 template<class T>
648 class n_pointer<T,1,C_TYPE,true>
649 {
650  T* p_p;
651  const size_t* p_st;
652  const tree_vec* p_v;
653 public:
654  typedef T value_type;
655  n_pointer(T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
656  value_type& operator[] (const size_t i) const
657  {
658  if( i >= p_v->n )
659  OUT_OF_RANGE( "n_pointer::operator[]" );
660  return *(p_p + i);
661  }
662 };
663 
664 template<class T, int N>
665 class const_n_pointer<T,N,ARPA_TYPE,false>
666 {
667  const T* p_p;
668  const size_t* p_st;
669  const tree_vec* p_v;
670 public:
671  typedef const_n_pointer<T,N-1,ARPA_TYPE,false> value_type;
672  const_n_pointer(const T* p, const size_t* st=NULL, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
673  const value_type operator[] (const size_t i) const
674  {
675  return value_type( *((T**)p_p+i) );
676  }
677 };
678 
679 template<class T, int N>
680 class const_n_pointer<T,N,C_TYPE,false>
681 {
682  const T* p_p;
683  const size_t* p_st;
684  const tree_vec* p_v;
685 public:
686  typedef const_n_pointer<T,N-1,C_TYPE,false> value_type;
687  const_n_pointer(const T* p, const size_t* st, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
688  const value_type operator[] (const size_t i) const
689  {
690  return value_type( p_p+i*p_st[0], p_st+1 );
691  }
692 };
693 
694 template<class T>
695 class const_n_pointer<T,1,ARPA_TYPE,false>
696 {
697  const T* p_p;
698  const size_t* p_st;
699  const tree_vec* p_v;
700 public:
701  typedef const T value_type;
702  const_n_pointer(const T* p, const size_t* st=NULL, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
703  value_type& operator[] (const size_t i) const
704  {
705  return *(p_p + i);
706  }
707 };
708 
709 template<class T>
710 class const_n_pointer<T,1,C_TYPE,false>
711 {
712  const T* p_p;
713  const size_t* p_st;
714  const tree_vec* p_v;
715 public:
716  typedef const T value_type;
717  const_n_pointer(const T* p, const size_t* st, const tree_vec* v=NULL) : p_p(p), p_st(st), p_v(v) {}
718  value_type& operator[] (const size_t i) const
719  {
720  return *(p_p + i);
721  }
722 };
723 
724 template<class T, int N>
725 class const_n_pointer<T,N,ARPA_TYPE,true>
726 {
727  const T* p_p;
728  const size_t* p_st;
729  const tree_vec* p_v;
730 public:
731  typedef const_n_pointer<T,N-1,ARPA_TYPE,true> value_type;
732  const_n_pointer(const T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
733  const value_type operator[] (const size_t i) const
734  {
735  if( i >= p_v->n )
736  OUT_OF_RANGE( "const_n_pointer::operator[]" );
737  return value_type( *((T**)p_p+i), NULL, &p_v->d[i] );
738  }
739 };
740 
741 template<class T, int N>
742 class const_n_pointer<T,N,C_TYPE,true>
743 {
744  const T* p_p;
745  const size_t* p_st;
746  const tree_vec* p_v;
747 public:
748  typedef const_n_pointer<T,N-1,C_TYPE,true> value_type;
749  const_n_pointer(const T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
750  const value_type operator[] (const size_t i) const
751  {
752  if( i >= p_v->n )
753  OUT_OF_RANGE( "const_n_pointer::operator[]" );
754  return value_type( p_p+i*p_st[0], p_st+1, &p_v->d[i] );
755  }
756 };
757 
758 template<class T>
759 class const_n_pointer<T,1,ARPA_TYPE,true>
760 {
761  const T* p_p;
762  const size_t* p_st;
763  const tree_vec* p_v;
764 public:
765  typedef const T value_type;
766  const_n_pointer(const T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
767  value_type& operator[] (const size_t i) const
768  {
769  if( i >= p_v->n )
770  OUT_OF_RANGE( "const_n_pointer::operator[]" );
771  return *(p_p + i);
772  }
773 };
774 
775 template<class T>
776 class const_n_pointer<T,1,C_TYPE,true>
777 {
778  const T* p_p;
779  const size_t* p_st;
780  const tree_vec* p_v;
781 public:
782  typedef const T value_type;
783  const_n_pointer(const T* p, const size_t* st, const tree_vec* v) : p_p(p), p_st(st), p_v(v) {}
784  value_type& operator[] (const size_t i) const
785  {
786  if( i >= p_v->n )
787  OUT_OF_RANGE( "const_n_pointer::operator[]" );
788  return *(p_p + i);
789  }
790 };
791 
792 //
912 //
913 
914 template<class T, int d, mem_layout ALLOC=MEM_LAYOUT_VAL, bool lgBC=lgBOUNDSCHECKVAL>
916 {
917  // ancillary data describing the memory layout of the multi_arr
919  T** p_psl[d-1]; // pointer arrays for ARPA structure
920  valarray<T> p_dsl; // this contains the actual data
921  T* p_ptr; // main pointer to allocated structure
922  T** p_ptr2; // used in debugger to get access to internal representation
923  T*** p_ptr3;
924  T**** p_ptr4;
925  T***** p_ptr5;
926  T****** p_ptr6;
927 
928 public:
929  typedef random_access_iterator_tag iterator_category;
930  typedef T value_type;
931  typedef T& reference;
932  typedef const T& const_reference;
933  typedef T* pointer;
934  typedef const T* const_pointer;
935  typedef size_t size_type;
936  typedef ptrdiff_t difference_type;
939 
940 private:
941  static const size_type npos = static_cast<size_type>(-1);
942 
943  void p_clear0()
944  {
945  p_g.clear();
946  for( int i=0; i < d-1; ++i )
947  delete[] p_psl[i];
948  p_dsl.resize(0);
949  }
950  void p_clear1()
951  {
952  for( int i=0; i < d-1; ++i )
953  p_psl[i] = NULL;
954  p_ptr = NULL;
955  p_ptr2 = NULL;
956  p_ptr3 = NULL;
957  p_ptr4 = NULL;
958  p_ptr5 = NULL;
959  p_ptr6 = NULL;
960  }
961 
962 public:
964  {
965  p_clear1();
966  }
968  {
969  p_clear1();
970  alloc( g );
971  }
973  {
974  p_clear1();
975  size_type index[] = { d1, d2 };
976  alloc( index );
977  }
979  {
980  p_clear1();
981  size_type index[] = { d1, d2, d3 };
982  alloc( index );
983  }
985  {
986  p_clear1();
987  size_type index[] = { d1, d2, d3, d4 };
988  alloc( index );
989  }
991  {
992  p_clear1();
993  size_type index[] = { d1, d2, d3, d4, d5 };
994  alloc( index );
995  }
997  {
998  p_clear1();
999  size_type index[] = { d1, d2, d3, d4, d5, d6 };
1000  alloc( index );
1001  }
1003  {
1004  p_clear1();
1005  *this = m;
1006  }
1008  {
1009  p_clear0();
1010  }
1011  void clear()
1012  {
1013  p_clear0();
1014  p_clear1();
1015  }
1016  const multi_arr& operator= (const multi_arr& m)
1017  {
1018  if( &m != this )
1019  {
1020  alloc( m.p_g );
1021  vals() = m.vals();
1022  }
1023  return *this;
1024  }
1025  const multi_arr& operator= (const T& val)
1026  {
1027  p_dsl = val;
1028  return *this;
1029  }
1030  void zero()
1031  {
1032  ASSERT( vals().size() == p_g.size );
1033  if( p_g.size > 0 )
1034  memset( data(), 0, p_g.size*sizeof(T) );
1035  }
1036  void invalidate()
1037  {
1038  ASSERT( vals().size() == p_g.size );
1039  invalidate_array( data(), p_g.size*sizeof(T) );
1040  }
1041 
1043  {
1044  ASSERT( vals().size() == 0 );
1045  const size_type index[] = { i1 };
1046  p_g.reserve( 1, index );
1047  }
1049  {
1050  ASSERT( vals().size() == 0 );
1051  const size_type index[] = { i1, i2 };
1052  p_g.reserve( 2, index );
1053  }
1055  {
1056  ASSERT( vals().size() == 0 );
1057  const size_type index[] = { i1, i2, i3 };
1058  p_g.reserve( 3, index );
1059  }
1061  {
1062  ASSERT( vals().size() == 0 );
1063  const size_type index[] = { i1, i2, i3, i4 };
1064  p_g.reserve( 4, index );
1065  }
1067  {
1068  ASSERT( vals().size() == 0 );
1069  const size_type index[] = { i1, i2, i3, i4, i5 };
1070  p_g.reserve( 5, index );
1071  }
1073  {
1074  ASSERT( vals().size() == 0 );
1075  const size_type index[] = { i1, i2, i3, i4, i5, i6 };
1076  p_g.reserve( 6, index );
1077  }
1078  void alloc()
1079  {
1080  p_g.finalize();
1081  static_assert( ALLOC == C_TYPE || ALLOC == ARPA_TYPE,
1082  "Allocation type must be C_TYPE or ARPA_TYPE" );
1083 
1084  if( ALLOC == ARPA_TYPE )
1085  {
1086  size_type n1[d], n2[d];
1087  // allocate the pointer arrays ( p_psl[0..d-2] ) and data ( p_dsl )
1088  for( int dim=0; dim < d; ++dim )
1089  {
1090  n1[dim] = n2[dim] = 0L;
1091  if( dim != d-1 )
1092  {
1093  ASSERT( p_psl[dim] == NULL );
1094  if( p_g.nsl[dim] > 0 )
1095  p_psl[dim] = new T*[ p_g.nsl[dim] ];
1096  }
1097  else
1098  {
1099  ASSERT( p_dsl.size() == 0 );
1100  p_dsl.resize( p_g.nsl[dim] );
1101  }
1102  }
1103  // now initialize all the pointer arrays
1104  p_setupArray( n1, n2, &p_g.v, 0 );
1105  p_ptr = (T*)p_psl[0];
1106  }
1107  else if( ALLOC == C_TYPE )
1108  {
1109  for( int i=0; i < d-1; ++i )
1110  p_psl[i] = NULL;
1111  ASSERT( p_dsl.size() == 0 );
1112  p_dsl.resize( p_g.st[0] );
1113  p_ptr = &p_dsl[0];
1114  }
1115  else
1116  {
1117  TotalInsanity();
1118  }
1119  p_ptr2 = (T**)p_ptr;
1120  p_ptr3 = (T***)p_ptr;
1121  p_ptr4 = (T****)p_ptr;
1122  p_ptr5 = (T*****)p_ptr;
1123  p_ptr6 = (T******)p_ptr;
1124  }
1125  // clone the geometry from another multi_arr
1127  {
1128  if( &g != &p_g )
1129  {
1130  clear();
1131  p_g = g;
1132  alloc();
1133  }
1134  }
1135  // set up a rectangular block of data with dimensions d1 x d2 x ....
1137  {
1138  size_type index[] = { d1, d2 };
1139  alloc( index );
1140  }
1142  {
1143  size_type index[] = { d1, d2, d3 };
1144  alloc( index );
1145  }
1147  {
1148  size_type index[] = { d1, d2, d3, d4 };
1149  alloc( index );
1150  }
1152  {
1153  size_type index[] = { d1, d2, d3, d4, d5 };
1154  alloc( index );
1155  }
1157  {
1158  size_type index[] = { d1, d2, d3, d4, d5, d6 };
1159  alloc( index );
1160  }
1161  void alloc(size_type index[])
1162  {
1163  for( int n=0; n < d; n++ )
1164  ASSERT( index[n] > 0 );
1165  clear();
1166  p_g.reserve_recursive( 0, index );
1167  alloc();
1168  }
1169 
1170 private:
1171  // helper routine for alloc(), this fills in the pointer arrays for the ARPA layout
1172  void p_setupArray( size_type n1[], size_type n2[], const tree_vec* g, size_type l )
1173  {
1174  for( size_type i=0; i < g->n; ++i )
1175  {
1176  // using int(l) is always safe and avoids warnings about the test
1177  // 'l < d-2' being always false when d == 2 (e.g. with g++ 4.6.0)
1178  if( int(l) < d-2 )
1179  {
1180  p_psl[l][n1[l]++] = (T*)(p_psl[l+1]+n2[l]);
1181  p_setupArray( n1, n2, &g->d[i], l+1 );
1182  }
1183  else
1184  {
1185  p_psl[l][n1[l]++] = &p_dsl[0]+n2[l];
1186  }
1187  n2[l] += g->d[i].n;
1188  }
1189  }
1190 
1191  // in the p_iterator methods the bound-checking part is split off into a separate
1192  // routine p_iterator_bc in order to make it easier for compilers to inline the code
1194  {
1195  if( lgBC )
1196  return p_iterator_bc( i1, i2 );
1197  else
1198  {
1199  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1200  return iterator( &(*t)[i1][i2] );
1201  }
1202  }
1204  {
1205  size_type index[] = { i1 };
1206  if( p_g.lgInbounds( 1, index ) )
1207  {
1208  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1209  size_type n = p_g.v.getvec( 1, index ).n;
1210  T* s = ( n > 0 ) ? &(*t)[i1][0] : NULL;
1211  if( i2 == npos )
1212  return iterator( s+n, s, s+n );
1213  else
1214  return iterator( s+i2, s, s+n );
1215  }
1216  else
1217  OUT_OF_RANGE( "multi_arr::p_iterator()" );
1218  }
1220  {
1221  if( lgBC )
1222  return p_iterator_bc( i1, i2, i3 );
1223  else
1224  {
1225  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1226  return iterator( &(*t)[i1][i2][i3] );
1227  }
1228  }
1230  {
1231  size_type index[] = { i1, i2 };
1232  if( p_g.lgInbounds( 2, index ) )
1233  {
1234  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1235  size_type n = p_g.v.getvec( 2, index ).n;
1236  T* s = ( n > 0 ) ? &(*t)[i1][i2][0] : NULL;
1237  if( i3 == npos )
1238  return iterator( s+n, s, s+n );
1239  else
1240  return iterator( s+i3, s, s+n );
1241  }
1242  else
1243  OUT_OF_RANGE( "multi_arr::p_iterator()" );
1244  }
1246  {
1247  if( lgBC )
1248  return p_iterator_bc(i1, i2, i3, i4);
1249  else
1250  {
1251  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1252  return iterator( &(*t)[i1][i2][i3][i4] );
1253  }
1254  }
1256  {
1257  size_type index[] = { i1, i2, i3 };
1258  if( p_g.lgInbounds( 3, index ) )
1259  {
1260  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1261  size_type n = p_g.v.getvec( 3, index ).n;
1262  T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][0] : NULL;
1263  if( i4 == npos )
1264  return iterator( s+n, s, s+n );
1265  else
1266  return iterator( s+i4, s, s+n );
1267  }
1268  else
1269  OUT_OF_RANGE( "multi_arr::p_iterator()" );
1270  }
1272  {
1273  if( lgBC )
1274  return p_iterator_bc(i1, i2, i3, i4, i5);
1275  else
1276  {
1277  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1278  return iterator( &(*t)[i1][i2][i3][i4][i5] );
1279  }
1280  }
1282  {
1283  size_type index[] = { i1, i2, i3, i4 };
1284  if( p_g.lgInbounds( 4, index ) )
1285  {
1286  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1287  size_type n = p_g.v.getvec( 4, index ).n;
1288  T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][i4][0] : NULL;
1289  if( i5 == npos )
1290  return iterator( s+n, s, s+n );
1291  else
1292  return iterator( s+i5, s, s+n );
1293  }
1294  else
1295  OUT_OF_RANGE( "multi_arr::p_iterator()" );
1296  }
1298  {
1299  if( lgBC )
1300  return p_iterator_bc(i1, i2, i3, i4, i5, i6);
1301  else
1302  {
1303  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1304  return iterator( &(*t)[i1][i2][i3][i4][i5][i6] );
1305  }
1306  }
1308  {
1309  size_type index[] = { i1, i2, i3, i4, i5 };
1310  if( p_g.lgInbounds( 5, index ) )
1311  {
1312  multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this);
1313  size_type n = p_g.v.getvec( 5, index ).n;
1314  T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][i4][i5][0] : NULL;
1315  if( i6 == npos )
1316  return iterator( s+n, s, s+n );
1317  else
1318  return iterator( s+i6, s, s+n );
1319  }
1320  else
1321  OUT_OF_RANGE( "multi_arr::p_iterator()" );
1322  }
1323 
1324 public:
1326  {
1327  return n_pointer<T,d,ALLOC,lgBC>( p_ptr, p_g.st+1, &p_g.v );
1328  }
1330  {
1331  return const_n_pointer<T,d,ALLOC,lgBC>( p_ptr, p_g.st+1, &p_g.v );
1332  }
1333  typedef n_pointer<T,d-1,ALLOC,lgBC> indexed_type;
1335  {
1336  return n_ptr()[i];
1337  }
1338  typedef const_n_pointer<T,d-1,ALLOC,lgBC> const_indexed_type;
1340  {
1341  return n_ptr()[i];
1342  }
1343 
1345  {
1346  size_type index[] = { i1, i2 };
1347  if( !p_g.lgInbounds( 2, index ) )
1348  OUT_OF_RANGE( "multi_arr::at()" );
1349  return (*this)[i1][i2];
1350  }
1352  {
1353  size_type index[] = { i1, i2 };
1354  if( !p_g.lgInbounds( 2, index ) )
1355  OUT_OF_RANGE( "multi_arr::at()" );
1356  return (*this)[i1][i2];
1357  }
1359  {
1360  size_type index[] = { i1, i2, i3 };
1361  if( !p_g.lgInbounds( 3, index ) )
1362  OUT_OF_RANGE( "multi_arr::at()" );
1363  return (*this)[i1][i2][i3];
1364  }
1366  {
1367  size_type index[] = { i1, i2, i3 };
1368  if( !p_g.lgInbounds( 3, index ) )
1369  OUT_OF_RANGE( "multi_arr::at()" );
1370  return (*this)[i1][i2][i3];
1371  }
1373  {
1374  size_type index[] = { i1, i2, i3, i4 };
1375  if( !p_g.lgInbounds( 4, index ) )
1376  OUT_OF_RANGE( "multi_arr::at()" );
1377  return (*this)[i1][i2][i3][i4];
1378  }
1380  {
1381  size_type index[] = { i1, i2, i3, i4 };
1382  if( !p_g.lgInbounds( 4, index ) )
1383  OUT_OF_RANGE( "multi_arr::at()" );
1384  return (*this)[i1][i2][i3][i4];
1385  }
1387  {
1388  size_type index[] = { i1, i2, i3, i4, i5 };
1389  if( !p_g.lgInbounds( 5, index ) )
1390  OUT_OF_RANGE( "multi_arr::at()" );
1391  return (*this)[i1][i2][i3][i4][i5];
1392  }
1394  {
1395  size_type index[] = { i1, i2, i3, i4, i5 };
1396  if( !p_g.lgInbounds( 5, index ) )
1397  OUT_OF_RANGE( "multi_arr::at()" );
1398  return (*this)[i1][i2][i3][i4][i5];
1399  }
1401  {
1402  size_type index[] = { i1, i2, i3, i4, i5, i6 };
1403  if( !p_g.lgInbounds( 6, index ) )
1404  OUT_OF_RANGE( "multi_arr::at()" );
1405  return (*this)[i1][i2][i3][i4][i5][i6];
1406  }
1408  {
1409  size_type index[] = { i1, i2, i3, i4, i5, i6 };
1410  if( !p_g.lgInbounds( 6, index ) )
1411  OUT_OF_RANGE( "multi_arr::at()" );
1412  return (*this)[i1][i2][i3][i4][i5][i6];
1413  }
1414 
1416  {
1417  return p_iterator(i1, i2);
1418  }
1420  {
1421  return p_iterator(i1, i2);
1422  }
1424  {
1425  return p_iterator(i1, i2, i3);
1426  }
1428  {
1429  return p_iterator(i1, i2, i3);
1430  }
1432  {
1433  return p_iterator(i1, i2, i3, i4);
1434  }
1436  {
1437  return p_iterator(i1, i2, i3, i4);
1438  }
1440  {
1441  return p_iterator(i1, i2, i3, i4, i5);
1442  }
1444  {
1445  return p_iterator(i1, i2, i3, i4, i5);
1446  }
1448  {
1449  return p_iterator(i1, i2, i3, i4, i5, i6);
1450  }
1452  {
1453  return p_iterator(i1, i2, i3, i4, i5, i6);
1454  }
1455 
1457  {
1458  return p_iterator(i1, 0);
1459  }
1461  {
1462  return p_iterator(i1, 0);
1463  }
1465  {
1466  return p_iterator(i1, i2, 0);
1467  }
1469  {
1470  return p_iterator(i1, i2, 0);
1471  }
1473  {
1474  return p_iterator(i1, i2, i3, 0);
1475  }
1477  {
1478  return p_iterator(i1, i2, i3, 0);
1479  }
1481  {
1482  return p_iterator(i1, i2, i3, i4, 0);
1483  }
1485  {
1486  return p_iterator(i1, i2, i3, i4, 0);
1487  }
1489  {
1490  return p_iterator(i1, i2, i3, i4, i5, 0);
1491  }
1493  {
1494  return p_iterator(i1, i2, i3, i4, i5, 0);
1495  }
1496 
1498  {
1499  if( lgBC )
1500  return p_iterator(i1, npos);
1501  else
1502  return p_iterator(i1, p_g.v.d[i1].n);
1503  }
1505  {
1506  if( lgBC )
1507  return p_iterator(i1, npos);
1508  else
1509  return p_iterator(i1, p_g.v.d[i1].n);
1510  }
1512  {
1513  if( lgBC )
1514  return p_iterator(i1, i2, npos);
1515  else
1516  return p_iterator(i1, i2, p_g.v.d[i1].d[i2].n);
1517  }
1519  {
1520  if( lgBC )
1521  return p_iterator(i1, i2, npos);
1522  else
1523  return p_iterator(i1, i2, p_g.v.d[i1].d[i2].n);
1524  }
1526  {
1527  if( lgBC )
1528  return p_iterator(i1, i2, i3, npos);
1529  else
1530  return p_iterator(i1, i2, i3, p_g.v.d[i1].d[i2].d[i3].n);
1531  }
1533  {
1534  if( lgBC )
1535  return p_iterator(i1, i2, i3, npos);
1536  else
1537  return p_iterator(i1, i2, i3, p_g.v.d[i1].d[i2].d[i3].n);
1538  }
1540  {
1541  if( lgBC )
1542  return p_iterator(i1, i2, i3, i4, npos);
1543  else
1544  return p_iterator(i1, i2, i3, i4, p_g.v.d[i1].d[i2].d[i3].d[i4].n);
1545  }
1547  {
1548  if( lgBC )
1549  return p_iterator(i1, i2, i3, i4, npos);
1550  else
1551  return p_iterator(i1, i2, i3, i4, p_g.v.d[i1].d[i2].d[i3].d[i4].n);
1552  }
1554  {
1555  if( lgBC )
1556  return p_iterator(i1, i2, i3, i4, i5, npos);
1557  else
1558  return p_iterator(i1, i2, i3, i4, i5, p_g.v.d[i1].d[i2].d[i3].d[i4].d[i5].n);
1559  }
1561  {
1562  if( lgBC )
1563  return p_iterator(i1, i2, i3, i4, i5, npos);
1564  else
1565  return p_iterator(i1, i2, i3, i4, i5, p_g.v.d[i1].d[i2].d[i3].d[i4].d[i5].n);
1566  }
1567 
1569  {
1570  return *begin(i1);
1571  }
1573  {
1574  return *begin(i1);
1575  }
1577  {
1578  return *begin(i1, i2);
1579  }
1581  {
1582  return *begin(i1, i2);
1583  }
1585  {
1586  return *begin(i1, i2, i3);
1587  }
1589  {
1590  return *begin(i1, i2, i3);
1591  }
1593  {
1594  return *begin(i1, i2, i3, i4);
1595  }
1597  {
1598  return *begin(i1, i2, i3, i4);
1599  }
1601  {
1602  return *begin(i1, i2, i3, i4, i5);
1603  }
1605  {
1606  return *begin(i1, i2, i3, i4, i5);
1607  }
1608 
1610  {
1611  return *(end(i1) - 1);
1612  }
1614  {
1615  return *(end(i1) - 1);
1616  }
1618  {
1619  return *(end(i1, i2) - 1);
1620  }
1622  {
1623  return *(end(i1, i2) - 1);
1624  }
1626  {
1627  return *(end(i1, i2, i3) - 1);
1628  }
1630  {
1631  return *(end(i1, i2, i3) - 1);
1632  }
1634  {
1635  return *(end(i1, i2, i3, i4) - 1);
1636  }
1638  {
1639  return *(end(i1, i2, i3, i4) - 1);
1640  }
1642  {
1643  return *(end(i1, i2, i3, i4, i5) - 1);
1644  }
1646  {
1647  return *(end(i1, i2, i3, i4, i5) - 1);
1648  }
1649 
1650  size_type size() const
1651  {
1652  return p_g.size;
1653  }
1655  {
1656  return p_g.size;
1657  }
1658  bool empty() const
1659  {
1660  for( int i=0; i < d-1; ++i )
1661  if( p_psl[i] != NULL )
1662  return false;
1663  return ( p_g.size == 0UL && p_dsl.size() == 0 );
1664  }
1665 
1667  {
1668  if( p_g.size > 0 )
1669  return get_ptr( p_dsl );
1670  else
1671  return NULL;
1672  }
1674  {
1675  if( p_g.size > 0 )
1676  return get_ptr( p_dsl );
1677  else
1678  return NULL;
1679  }
1680 
1682  {
1683  return p_g;
1684  }
1685 
1686  valarray<T>& vals()
1687  {
1688  return p_dsl;
1689  }
1690  const valarray<T>& vals() const
1691  {
1692  return p_dsl;
1693  }
1694 };
1695 
1696 // predefine commonly used iterators
1707 
1718 
1729 
1740 
1741 // on Mac systems these instantiations need to be extern in order to avoid duplicate symbols
1742 #define INSTANTIATE_MULTI_ARR( TYPE, BC ) \
1743 template class pntr<TYPE,BC>; \
1744 template class const_pntr<TYPE,BC>;
1745 
1746 template<class T, bool lgBC=lgBOUNDSCHECKVAL>
1748 {
1749  size_t p_size; // number of elements allocated
1750  long p_begin; // first valid array index
1751  long p_end; // one beyond last valid array index
1752  bool p_init; // set true when alloc() has been called
1753 
1754  T* p_ptr_alloc; // pointer to start of allocated data
1755  T* p_ptr; // pointer used for calculating array indices
1756 
1757 public:
1758  typedef random_access_iterator_tag iterator_category;
1759  typedef T value_type;
1760  typedef T& reference;
1761  typedef const T& const_reference;
1762  typedef T* pointer;
1763  typedef const T* const_pointer;
1764  typedef long size_type;
1765  typedef ptrdiff_t difference_type;
1768 
1769 private:
1770  void p_clear0()
1771  {
1773  p_ptr_alloc = NULL;
1774  }
1775  void p_clear1()
1776  {
1777  p_size = 0;
1778  p_begin = 0;
1779  p_end = 0;
1780  p_init = false;
1781  p_ptr_alloc = NULL;
1782  p_ptr = NULL;
1783  }
1784  T* p_alloc(size_t size) const
1785  {
1786  return new T[size];
1787  }
1788  void p_free(T* p) const
1789  {
1790  delete[] p;
1791  }
1792 
1793 public:
1795  {
1796  p_clear1();
1797  }
1799  {
1800  p_clear1();
1801  alloc( begin, end );
1802  }
1803  flex_arr(const flex_arr& f)
1804  {
1805  p_clear1();
1806  *this = f;
1807  }
1809  {
1810  p_clear0();
1811  }
1812  const flex_arr& operator= (const flex_arr& f)
1813  {
1814  if( &f != this )
1815  {
1816  clear();
1817  p_size = f.p_size;
1818  p_begin = f.p_begin;
1819  p_end = f.p_end;
1820  p_init = f.p_init;
1821  if( f.p_ptr_alloc != NULL )
1822  {
1824  pointer p = p_ptr_alloc;
1825  const_pointer fp = f.p_ptr_alloc;
1826  for( size_type i=0; i < p_end-p_begin; ++i )
1827  *p++ = *fp++;
1829  }
1830  }
1831  return *this;
1832  }
1833  void clear()
1834  {
1835  p_clear0();
1836  p_clear1();
1837  }
1838  void zero()
1839  {
1840  if( p_size > 0 )
1841  memset( p_ptr_alloc, 0, p_size*sizeof(T) );
1842  }
1843  void invalidate()
1844  {
1845  invalidate_array( p_ptr_alloc, p_size*sizeof(T) );
1846  }
1847 
1848  // reserve memory for the array
1850  {
1851  // make sure we start with a clean slate...
1852  clear();
1853  if( size > 0 )
1854  {
1855  ASSERT( p_ptr_alloc == NULL );
1856  p_ptr_alloc = p_alloc(size);
1857  p_size = (size_t)size;
1858  }
1859  }
1860  // allocate array with index between begin <= ind < end
1861  // memory is allocated here, if not already done with reserve() before
1863  {
1864  if( (size_t)max(end-begin,0) > p_size )
1865  {
1866  clear();
1867 
1868  ASSERT( p_ptr_alloc == NULL );
1869  p_ptr_alloc = p_alloc(end-begin);
1870  p_ptr = p_ptr_alloc - begin;
1871  p_size = (size_t)(end-begin);
1872  }
1873  else
1874  {
1875  // store was already allocated with reserve()
1876  p_ptr = p_ptr_alloc - begin;
1877  }
1878  p_begin = begin;
1879  p_end = end;
1880  p_init = true;
1881  }
1882  // adjust upper limit of array, reallocate store if necessary
1884  {
1885  ASSERT( p_init );
1886  if( (size_t)max(end-p_begin,0) > p_size )
1887  {
1888  // reallocate the store
1889  T* nptr_alloc = p_alloc(end-p_begin);
1890  T* nptr = nptr_alloc - p_begin;
1891  // copy store over using operator= from T, using memcpy would be a bug!
1892  // this could trip valgrind / purify since we don't know if this is initialized
1893  // there is nothing safe we can do here, so the caller should take care of this
1894  // note that we ignore fields above p_end, we assume nothing of interest is there
1895  if( p_ptr_alloc != NULL && p_ptr != NULL )
1896  {
1897  for( size_type i=p_begin; i < p_end; ++i )
1898  nptr[i] = p_ptr[i];
1900  }
1901  p_ptr_alloc = nptr_alloc;
1902  p_ptr = nptr;
1903  p_size = (size_t)(end-p_begin);
1904  }
1905  p_end = end;
1906  }
1907 
1908 private:
1909  // the p_pointer() method below defines indexing into the flex_arr
1911  {
1912  return p_ptr+i;
1913  }
1914 
1916  {
1917  if( lgBC )
1919  else
1920  return iterator( p_pointer(i) );
1921  }
1922 
1923  bool p_lgInbounds(size_type i) const
1924  {
1925  return ( i >= p_begin && i < p_end );
1926  }
1927 
1929  {
1930  if( lgBC )
1931  {
1932  if( ! p_lgInbounds( i ) )
1933  OUT_OF_RANGE( "flex_arr::p_index()" );
1934  }
1935  return *p_pointer(i);
1936  }
1937 
1938 public:
1940  {
1941  return reference(p_index(i));
1942  }
1944  {
1945  return const_reference(p_index(i));
1946  }
1947 
1949  {
1950  if( ! p_lgInbounds(i) )
1951  OUT_OF_RANGE( "flex_arr::at()" );
1952  return (*this)[i];
1953  }
1955  {
1956  if( ! p_lgInbounds(i) )
1957  OUT_OF_RANGE( "flex_arr::at()" );
1958  return (*this)[i];
1959  }
1960 
1962  {
1963  return iterator(p_iterator(i));
1964  }
1966  {
1967  return const_iterator(p_iterator(i));
1968  }
1969 
1970  // \todo add: assign, swap?, ... (go over stl_vector.h)
1971 
1973  {
1974  return ptr(p_begin);
1975  }
1977  {
1978  return ptr(p_begin);
1979  }
1980 
1982  {
1983  return ptr(p_end);
1984  }
1986  {
1987  return ptr(p_end);
1988  }
1989 
1991  {
1992  return *begin();
1993  }
1995  {
1996  return *begin();
1997  }
1998 
2000  {
2001  return *(end()-1);
2002  }
2004  {
2005  return *(end()-1);
2006  }
2007 
2008  size_type size() const
2009  {
2010  return max(p_end-p_begin,0);
2011  }
2013  {
2014  return p_size;
2015  }
2016  bool empty() const
2017  {
2018  return ( size() == 0 );
2019  }
2020 
2022  {
2023  return p_ptr_alloc;
2024  }
2026  {
2027  return p_ptr_alloc;
2028  }
2029 
2031  {
2032  return p_ptr;
2033  }
2035  {
2036  return p_ptr;
2037  }
2038 };
2039 
2040 // predefine commonly used iterators
2049 
2050 #endif /* CONTAINER_CLASSES_H_ */
const_pointer data() const
Definition: container_classes.h:2025
const_iterator end(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1560
multi_arr< realnum, 2 >::const_iterator mr2ci
Definition: container_classes.h:1720
T * operator->() const
Definition: container_classes.h:102
iterator begin(size_type i1)
Definition: container_classes.h:1456
random_access_iterator_tag iterator_category
Definition: container_classes.h:929
iterator p_iterator_bc(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1229
multi_arr< double, 2 >::const_iterator md2ci
Definition: container_classes.h:1731
void p_setupArray(size_type n1[], size_type n2[], const tree_vec *g, size_type l)
Definition: container_classes.h:1172
pntr< T, lgBC > iterator
Definition: container_classes.h:937
void alloc(size_type d1, size_type d2, size_type d3, size_type d4, size_type d5)
Definition: container_classes.h:1151
const_n_pointer(const T *p, const size_t *st=NULL, const tree_vec *v=NULL)
Definition: container_classes.h:672
iterator p_iterator(size_type i1, size_type i2) const
Definition: container_classes.h:1193
reference at(size_type i)
Definition: container_classes.h:1948
reference back(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1641
const T * const_pointer
Definition: container_classes.h:1763
multi_arr< long, 5 >::iterator ml5i
Definition: container_classes.h:1714
reference back(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1625
size_type size
Definition: container_classes.h:282
const T value_type
Definition: container_classes.h:701
valarray< T > p_dsl
Definition: container_classes.h:920
multi_geom()
Definition: container_classes.h:304
const size_t * p_st
Definition: container_classes.h:555
multi_arr< realnum, 6 >::iterator mr6i
Definition: container_classes.h:1727
const_reference back(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1629
void clear()
Definition: container_classes.h:317
n_pointer(T *p, const size_t *st, const tree_vec *v=NULL)
Definition: container_classes.h:559
basic_pntr(T *p0)
Definition: container_classes.h:65
const_iterator ptr(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1427
const_reference at(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1379
pntr & operator++()
Definition: container_classes.h:130
T value_type
Definition: container_classes.h:654
const_pntr & operator--()
Definition: container_classes.h:164
multi_geom(const multi_geom &m)
Definition: container_classes.h:308
pntr - interface class to replace normal pointers
Definition: container_classes.h:121
const_pntr(const pntr< T, lgBC > &t)
Definition: container_classes.h:159
flex_arr()
Definition: container_classes.h:1794
iterator begin(size_type i1, size_type i2)
Definition: container_classes.h:1464
iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6)
Definition: container_classes.h:1447
const_iterator begin(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1476
const_reference at(size_type i) const
Definition: container_classes.h:1954
T * get_ptr(T *v)
Definition: cddefines.h:1115
NORETURN void TotalInsanity(void)
Definition: service.cpp:1174
void alloc()
Definition: container_classes.h:1078
T & operator[](const ptrdiff_t n) const
Definition: container_classes.h:106
ptrdiff_t difference_type
Definition: container_classes.h:58
flex_arr< realnum >::const_iterator farci
Definition: container_classes.h:2046
void p_set_vals(T *p0, T *p1, T *p2)
Definition: container_classes.h:41
const T * const_pointer
Definition: container_classes.h:934
static const size_type npos
Definition: container_classes.h:941
long size_type
Definition: container_classes.h:1764
void zero()
Definition: container_classes.h:1030
const_iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1435
multi_arr< bool, 5 >::const_iterator mb5ci
Definition: container_classes.h:1704
const T value_type
Definition: container_classes.h:765
const_reference at(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1393
iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6) const
Definition: container_classes.h:1297
const_reference back(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1645
T * p_p
Definition: container_classes.h:539
bool operator!=(const basic_pntr &t) const
Definition: container_classes.h:112
const_pointer data() const
Definition: container_classes.h:1673
const tree_vec * p_v
Definition: container_classes.h:714
multi_arr< long, 3 >::iterator ml3i
Definition: container_classes.h:1710
reference at(size_type i1, size_type i2)
Definition: container_classes.h:1344
void p_clear0()
Definition: container_classes.h:943
reference front(size_type i1, size_type i2)
Definition: container_classes.h:1576
void p_clear0()
Definition: container_classes.h:1770
multi_arr< long, 2 >::const_iterator ml2ci
Definition: container_classes.h:1709
const tree_vec * p_v
Definition: container_classes.h:652
T value_type
Definition: container_classes.h:930
basic_pntr()
Definition: container_classes.h:69
multi_arr< long, 2 >::iterator ml2i
Definition: container_classes.h:1708
const_iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1443
const tree_vec & getvec(const size_type i, const size_type index[]) const
Definition: container_classes.h:263
const tree_vec * p_v
Definition: container_classes.h:571
void invalidate_array(T *p, size_t size)
Definition: cddefines.h:1097
size_type size() const
Definition: container_classes.h:1650
const_pntr - same as pntr, except that it replaces const pointers rather than normal pointers ...
Definition: container_classes.h:151
const_pntr< T, lgBC > const_iterator
Definition: container_classes.h:1767
void reserve(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6)
Definition: container_classes.h:1072
const tree_vec * p_v
Definition: container_classes.h:635
void reserve(const size_type n, const size_type index[])
Definition: container_classes.h:345
bool operator<=(const basic_pntr &t) const
Definition: container_classes.h:114
iterator end()
Definition: container_classes.h:1981
reference front(size_type i1)
Definition: container_classes.h:1568
void p_clear0()
Definition: container_classes.h:205
basic_pntr & operator++()
Definition: container_classes.h:80
Definition: container_classes.h:1747
void reserve(size_type i1, size_type i2)
Definition: container_classes.h:1048
size_type st[d]
size of each dimension (only used in C_TYPE layout)
Definition: container_classes.h:284
iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1271
size_t p_size
Definition: container_classes.h:1749
const_n_pointer(const T *p, const size_t *st, const tree_vec *v=NULL)
Definition: container_classes.h:717
reference operator[](size_type i)
Definition: container_classes.h:1939
multi_arr< realnum, 3 >::const_iterator mr3ci
Definition: container_classes.h:1722
flex_arr< realnum >::iterator fari
Definition: container_classes.h:2045
const T * p_p
Definition: container_classes.h:778
const tree_vec * p_v
Definition: container_classes.h:541
n_pointer(T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:638
const size_t * p_st
Definition: container_classes.h:668
T value_type
Definition: container_classes.h:52
void invalidate()
Definition: container_classes.h:1843
const_n_pointer< T, d-1, ALLOC, lgBC > const_indexed_type
Definition: container_classes.h:1338
T *** p_ptr3
Definition: container_classes.h:923
const tree_vec * p_v
Definition: container_classes.h:669
iterator ptr(size_type i1, size_type i2)
Definition: container_classes.h:1415
const_iterator begin(size_type i1) const
Definition: container_classes.h:1460
void clear()
Definition: container_classes.h:1011
iterator end(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1553
void reserve(size_type size)
Definition: container_classes.h:1849
T ** p_ptr2
Definition: container_classes.h:922
const T & operator[](const ptrdiff_t n) const
Definition: container_classes.h:177
T * pointer
Definition: container_classes.h:55
const_reference back(size_type i1) const
Definition: container_classes.h:1613
NORETURN void OUT_OF_RANGE(const char *str)
Definition: cddefines.h:646
random_access_iterator_tag iterator_category
Definition: container_classes.h:1758
tree_vec * d
Definition: container_classes.h:202
reference at(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6)
Definition: container_classes.h:1400
const tree_vec * p_v
Definition: container_classes.h:601
multi_arr< long, 4 >::const_iterator ml4ci
Definition: container_classes.h:1713
tree_vec & getvec(const size_type i, const size_type index[])
Definition: container_classes.h:256
flex_arr(const flex_arr &f)
Definition: container_classes.h:1803
const size_t * p_st
Definition: container_classes.h:683
multi_arr< long, 3 >::const_iterator ml3ci
Definition: container_classes.h:1711
multi_arr< bool, 5 >::iterator mb5i
Definition: container_classes.h:1703
~basic_pntr()
Definition: container_classes.h:77
void p_free(T *p) const
Definition: container_classes.h:1788
T * p_p
Definition: container_classes.h:569
const size_t * p_st
Definition: container_classes.h:698
const_pointer ptr0() const
Definition: container_classes.h:2034
n_pointer< T, N-1, C_TYPE, true > value_type
Definition: container_classes.h:620
multi_arr< bool, 4 >::iterator mb4i
Definition: container_classes.h:1701
void reserve(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1054
size_type n
Definition: container_classes.h:201
multi_arr< bool, 2 >::const_iterator mb2ci
Definition: container_classes.h:1698
const_reference front(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1588
size_type capacity() const
Definition: container_classes.h:2012
pntr< T, lgBC > iterator
Definition: container_classes.h:1766
basic_pntr & operator+=(const ptrdiff_t n)
Definition: container_classes.h:95
iterator end(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1539
void zero()
Definition: container_classes.h:1838
bool operator>=(const basic_pntr &t) const
Definition: container_classes.h:116
const_n_pointer(const T *p, const size_t *st=NULL, const tree_vec *v=NULL)
Definition: container_classes.h:702
const_reference front(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1596
const_reference front(size_type i1, size_type i2) const
Definition: container_classes.h:1580
reference back()
Definition: container_classes.h:1999
basic_pntr(T *p0, T *p1, T *p2)
Definition: container_classes.h:61
const const_n_pointer< T, d, ALLOC, lgBC > n_ptr() const
Definition: container_classes.h:1329
n_pointer(T *p, const size_t *st=NULL, const tree_vec *v=NULL)
Definition: container_classes.h:574
const_pntr(T *p0, T *p1, T *p2)
Definition: container_classes.h:156
bool p_init
Definition: container_classes.h:1752
const_pntr & operator+=(const ptrdiff_t n)
Definition: container_classes.h:166
flex_arr(size_type begin, size_type end)
Definition: container_classes.h:1798
void p_clear0()
sizes of each of the pointer arrays
Definition: container_classes.h:288
const_reference back(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1637
const T * p_p
Definition: container_classes.h:682
const_iterator end(size_type i1) const
Definition: container_classes.h:1504
static const int p_nd
Definition: container_classes.h:28
n_pointer< T, N-1, C_TYPE, false > value_type
Definition: container_classes.h:558
bool empty() const
Definition: container_classes.h:2016
const_iterator end(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1546
const_iterator begin() const
Definition: container_classes.h:1976
random_access_iterator_tag iterator_category
Definition: container_classes.h:51
size_type size() const
Definition: container_classes.h:2008
multi_arr(size_type d1, size_type d2, size_type d3, size_type d4)
Definition: container_classes.h:984
multi_arr< bool, 2 >::iterator mb2i
Definition: container_classes.h:1697
T * p_p
Definition: container_classes.h:633
const T * p_p
Definition: container_classes.h:712
size_t size_type
Definition: container_classes.h:57
T **** p_ptr4
Definition: container_classes.h:924
const flex_arr & operator=(const flex_arr &f)
Definition: container_classes.h:1812
const multi_geom< d, ALLOC > & clone() const
Definition: container_classes.h:1681
basic_pntr & operator--()
Definition: container_classes.h:86
void finalize(void)
Definition: container_classes.h:380
reference at(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1372
const_reference at(size_type i1, size_type i2) const
Definition: container_classes.h:1351
size_type capacity() const
Definition: container_classes.h:1654
flex_arr< double >::iterator fadi
Definition: container_classes.h:2047
iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1431
const_n_pointer< T, N-1, C_TYPE, true > value_type
Definition: container_classes.h:748
void p_setupArray(size_type n1[], size_type n2[], const tree_vec *w, size_type l)
Definition: container_classes.h:409
pointer p_pointer(size_type i) const
Definition: container_classes.h:1910
n_pointer(T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:655
const size_t * p_st
Definition: container_classes.h:634
multi_arr(size_type d1, size_type d2, size_type d3, size_type d4, size_type d5, size_type d6)
Definition: container_classes.h:996
const size_t * p_st
Definition: container_classes.h:713
const_iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6) const
Definition: container_classes.h:1451
multi_arr< long, 6 >::iterator ml6i
Definition: container_classes.h:1716
multi_geom< d, ALLOC > p_g
Definition: container_classes.h:918
bool operator==(const basic_pntr &t) const
Definition: container_classes.h:111
void alloc(size_type d1, size_type d2)
Definition: container_classes.h:1136
const tree_vec * p_v
Definition: container_classes.h:780
const_pntr< T, lgBC > const_iterator
Definition: container_classes.h:938
iterator ptr(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1439
const tree_vec * p_v
Definition: container_classes.h:684
~multi_arr()
Definition: container_classes.h:1007
Definition: container_classes.h:915
const_pntr()
Definition: container_classes.h:157
iterator end(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1525
const T value_type
Definition: container_classes.h:716
const size_t * p_st
Definition: container_classes.h:651
void alloc(size_type d1, size_type d2, size_type d3, size_type d4)
Definition: container_classes.h:1146
T * p_ptr
Definition: container_classes.h:1755
multi_arr< bool, 3 >::iterator mb3i
Definition: container_classes.h:1699
const size_t * p_st
Definition: container_classes.h:762
iterator p_iterator(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1219
const_iterator begin(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1484
const indexed_type operator[](size_type i)
Definition: container_classes.h:1334
ptrdiff_t difference_type
Definition: container_classes.h:936
const_n_pointer< T, N-1, ARPA_TYPE, true > value_type
Definition: container_classes.h:731
ptrdiff_t difference_type
Definition: container_classes.h:1765
const T * operator->() const
Definition: container_classes.h:176
iterator p_iterator_bc(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6) const
Definition: container_classes.h:1307
multi_arr< double, 5 >::const_iterator md5ci
Definition: container_classes.h:1737
const pntr operator-(const ptrdiff_t n) const
Definition: container_classes.h:136
pntr(T *p0)
Definition: container_classes.h:125
multi_arr< double, 5 >::iterator md5i
Definition: container_classes.h:1736
Definition: container_classes.h:534
const T & const_reference
Definition: container_classes.h:1761
iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1245
const tree_vec & operator=(const tree_vec &m)
Definition: container_classes.h:239
const T & operator*() const
Definition: container_classes.h:175
multi_arr(const multi_geom< d, ALLOC > &g)
Definition: container_classes.h:967
void invalidate()
Definition: container_classes.h:1036
T ** p_psl[d-1]
Definition: container_classes.h:919
reference p_index(size_type i) const
Definition: container_classes.h:1928
const tree_vec * p_v
Definition: container_classes.h:699
const_pntr(T *p0)
Definition: container_classes.h:155
flex_arr< double >::const_iterator fadci
Definition: container_classes.h:2048
pointer data()
Definition: container_classes.h:2021
const_iterator begin(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1492
const size_t * p_st
Definition: container_classes.h:600
const_reference front(size_type i1) const
Definition: container_classes.h:1572
void p_clear1()
Definition: container_classes.h:950
Definition: container_classes.h:12
const pntr< T, lgBC > operator+(const ptrdiff_t n, const pntr< T, lgBC > &t)
Definition: container_classes.h:142
reference at(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1386
const n_pointer< T, d, ALLOC, lgBC > n_ptr()
Definition: container_classes.h:1325
const_iterator end(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1532
const_iterator begin(size_type i1, size_type i2) const
Definition: container_classes.h:1468
flex_arr< long >::const_iterator falci
Definition: container_classes.h:2044
const_pntr & operator-=(const ptrdiff_t n)
Definition: container_classes.h:170
long max(int a, long b)
Definition: cddefines.h:821
const_iterator end() const
Definition: container_classes.h:1985
bool p_lgInbounds(size_type i) const
Definition: container_classes.h:1923
multi_arr< realnum, 3 >::iterator mr3i
Definition: container_classes.h:1721
reference front()
Definition: container_classes.h:1990
pntr & operator--()
Definition: container_classes.h:132
T & reference
Definition: container_classes.h:1760
T * p_p
Definition: container_classes.h:554
basic_pntr & operator=(const basic_pntr &)=default
multi_arr(const multi_arr &m)
Definition: container_classes.h:1002
size_type nsl[d]
stride for each dimension (only used in C_TYPE layout)
Definition: container_classes.h:285
T & reference
Definition: container_classes.h:931
const_n_pointer(const T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:732
const multi_geom & operator=(const multi_geom &m)
Definition: container_classes.h:322
Definition: container_classes.h:275
reference back(size_type i1)
Definition: container_classes.h:1609
Definition: atmdat.h:44
#define NULL
Definition: cddefines.h:115
void clear()
Definition: container_classes.h:234
multi_arr(size_type d1, size_type d2, size_type d3, size_type d4, size_type d5)
Definition: container_classes.h:990
const_n_pointer(const T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:783
basic_pntr & operator-=(const ptrdiff_t n)
Definition: container_classes.h:96
bool lgInbounds(const size_type n, const size_type index[]) const
Definition: container_classes.h:338
const_reference front() const
Definition: container_classes.h:1994
multi_arr< realnum, 4 >::iterator mr4i
Definition: container_classes.h:1723
tree_vec(const tree_vec &m)
Definition: container_classes.h:225
T value_type
Definition: container_classes.h:637
reference back(size_type i1, size_type i2)
Definition: container_classes.h:1617
n_pointer(T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:604
reference front(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1584
const T * p_p
Definition: container_classes.h:727
const_reference back() const
Definition: container_classes.h:2003
iterator p_iterator_bc(size_type i1, size_type i2, size_type i3, size_type i4) const
Definition: container_classes.h:1255
const T * p_p
Definition: container_classes.h:744
T * pointer
Definition: container_classes.h:1762
const_pntr & operator++()
Definition: container_classes.h:162
reference at(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1358
const size_t * p_st
Definition: container_classes.h:779
Definition: container_classes.h:12
multi_arr< double, 4 >::iterator md4i
Definition: container_classes.h:1734
iterator p_iterator_bc(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1281
iterator begin(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1472
T ***** p_ptr5
Definition: container_classes.h:925
void reserve_recursive(const size_type n, size_type index[])
Definition: container_classes.h:359
bool operator>(const basic_pntr &t) const
Definition: container_classes.h:115
valarray< T > & vals()
Definition: container_classes.h:1686
multi_arr(size_type d1, size_type d2, size_type d3)
Definition: container_classes.h:978
const T * p_p
Definition: container_classes.h:667
const tree_vec * p_v
Definition: container_classes.h:586
tree_vec v
Definition: container_classes.h:280
#define ASSERT(exp)
Definition: cddefines.h:637
multi_arr< realnum, 2 >::iterator mr2i
Definition: container_classes.h:1719
T * p_p
Definition: container_classes.h:616
T * p_alloc(size_t size) const
Definition: container_classes.h:1784
void p_clear1()
Definition: container_classes.h:292
multi_arr< realnum, 4 >::const_iterator mr4ci
Definition: container_classes.h:1724
const T value_type
Definition: container_classes.h:782
iterator end(size_type i1, size_type i2)
Definition: container_classes.h:1511
const tree_vec * p_v
Definition: container_classes.h:729
void reserve(size_type i1)
Definition: container_classes.h:1042
multi_arr< bool, 6 >::const_iterator mb6ci
Definition: container_classes.h:1706
void realloc(size_type end)
Definition: container_classes.h:1883
iterator begin(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1480
mem_layout
Definition: container_classes.h:12
n_pointer< T, N-1, ARPA_TYPE, true > value_type
Definition: container_classes.h:603
T value_type
Definition: container_classes.h:1759
const_iterator ptr(size_type i1, size_type i2) const
Definition: container_classes.h:1419
n_pointer(T *p, const size_t *st=NULL, const tree_vec *v=NULL)
Definition: container_classes.h:544
T * p_p
Definition: container_classes.h:650
iterator end(size_type i1)
Definition: container_classes.h:1497
pntr(T *p0, T *p1, T *p2)
Definition: container_classes.h:126
iterator p_iterator_bc(size_type i1, size_type i2) const
Definition: container_classes.h:1203
multi_arr< double, 2 >::iterator md2i
Definition: container_classes.h:1730
pntr()
Definition: container_classes.h:127
n_pointer(T *p, const size_t *st, const tree_vec *v=NULL)
Definition: container_classes.h:589
n_pointer(T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:621
bool empty() const
Definition: container_classes.h:1658
const tree_vec * p_v
Definition: container_classes.h:556
static const int32 MA_VERS[ML_TOP]
Definition: container_classes.h:15
const_iterator end(size_type i1, size_type i2) const
Definition: container_classes.h:1518
const size_t * p_st
Definition: container_classes.h:540
multi_arr< long, 5 >::const_iterator ml5ci
Definition: container_classes.h:1715
void alloc(size_type d1, size_type d2, size_type d3, size_type d4, size_type d5, size_type d6)
Definition: container_classes.h:1156
const tree_vec * p_v
Definition: container_classes.h:618
const_n_pointer(const T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:749
const tree_vec * p_v
Definition: container_classes.h:763
T * p_p[p_nd]
Definition: container_classes.h:29
T * p_p
Definition: container_classes.h:599
multi_arr< double, 6 >::const_iterator md6ci
Definition: container_classes.h:1739
const_reference at(size_type i1, size_type i2, size_type i3) const
Definition: container_classes.h:1365
pointer data()
Definition: container_classes.h:1666
multi_arr< bool, 4 >::const_iterator mb4ci
Definition: container_classes.h:1702
const T & const_reference
Definition: container_classes.h:54
const T * const_pointer
Definition: container_classes.h:56
iterator begin(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1488
const T * p_p
Definition: container_classes.h:697
void clear()
Definition: container_classes.h:1833
const T * p_p
Definition: container_classes.h:761
iterator begin()
Definition: container_classes.h:1972
size_t size_type
Definition: container_classes.h:199
multi_arr< bool, 3 >::const_iterator mb3ci
Definition: container_classes.h:1700
long p_begin
Definition: container_classes.h:1750
T * p_ptr
Definition: container_classes.h:921
Definition: container_classes.h:26
T * pointer
Definition: container_classes.h:933
T * p_p
Definition: container_classes.h:584
multi_arr< double, 3 >::const_iterator md3ci
Definition: container_classes.h:1733
reference front(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1592
T * p_index_checked(const ptrdiff_t n) const
Definition: container_classes.h:31
multi_arr(size_type d1, size_type d2)
Definition: container_classes.h:972
~flex_arr()
Definition: container_classes.h:1808
const valarray< T > & vals() const
Definition: container_classes.h:1690
void reserve(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1066
flex_arr< long >::iterator fali
Definition: container_classes.h:2043
const_iterator ptr(size_type i) const
Definition: container_classes.h:1965
multi_arr< long, 6 >::const_iterator ml6ci
Definition: container_classes.h:1717
reference front(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5)
Definition: container_classes.h:1600
n_pointer< T, N-1, ARPA_TYPE, false > value_type
Definition: container_classes.h:543
void p_clear1()
Definition: container_classes.h:214
const_reference at(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6) const
Definition: container_classes.h:1407
const_n_pointer(const T *p, const size_t *st, const tree_vec *v=NULL)
Definition: container_classes.h:687
multi_arr< double, 6 >::iterator md6i
Definition: container_classes.h:1738
n_pointer< T, d-1, ALLOC, lgBC > indexed_type
Definition: container_classes.h:1333
multi_arr< double, 4 >::const_iterator md4ci
Definition: container_classes.h:1735
const tree_vec * p_v
Definition: container_classes.h:746
void alloc(size_type begin, size_type end)
Definition: container_classes.h:1862
Definition: container_classes.h:533
multi_arr< double, 3 >::iterator md3i
Definition: container_classes.h:1732
void alloc(size_type index[])
Definition: container_classes.h:1161
const size_t * p_st
Definition: container_classes.h:617
const const_pntr operator-(const ptrdiff_t n) const
Definition: container_classes.h:183
const T & const_reference
Definition: container_classes.h:932
void alloc(size_type d1, size_type d2, size_type d3)
Definition: container_classes.h:1141
void alloc(const multi_geom< d, ALLOC > &g)
Definition: container_classes.h:1126
void reserve(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1060
const_reference back(size_type i1, size_type i2) const
Definition: container_classes.h:1621
~tree_vec()
Definition: container_classes.h:230
tree_vec - a simple class to store the bounds checking information for multi_arr
Definition: container_classes.h:197
T & reference
Definition: container_classes.h:53
reference back(size_type i1, size_type i2, size_type i3, size_type i4)
Definition: container_classes.h:1633
size_t size_type
Definition: container_classes.h:935
long p_end
Definition: container_classes.h:1751
multi_arr()
Definition: container_classes.h:963
tree_vec()
Definition: container_classes.h:221
T value_type
Definition: container_classes.h:588
flex_arr< bool >::const_iterator fabci
Definition: container_classes.h:2042
T value_type
Definition: container_classes.h:573
iterator ptr(size_type i1, size_type i2, size_type i3)
Definition: container_classes.h:1423
bool operator<(const basic_pntr &t) const
Definition: container_classes.h:113
const_n_pointer< T, N-1, C_TYPE, false > value_type
Definition: container_classes.h:686
const_reference front(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const
Definition: container_classes.h:1604
const size_t * p_st
Definition: container_classes.h:745
multi_arr< realnum, 6 >::const_iterator mr6ci
Definition: container_classes.h:1728
const_n_pointer(const T *p, const size_t *st, const tree_vec *v)
Definition: container_classes.h:766
Definition: container_classes.h:12
flex_arr< bool >::iterator fabi
Definition: container_classes.h:2041
multi_arr< realnum, 5 >::iterator mr5i
Definition: container_classes.h:1725
const_n_pointer< T, N-1, ARPA_TYPE, false > value_type
Definition: container_classes.h:671
multi_arr< realnum, 5 >::const_iterator mr5ci
Definition: container_classes.h:1726
void p_clear1()
Definition: container_classes.h:1775
Definition: container_classes.h:12
const size_t * p_st
Definition: container_classes.h:570
multi_arr< bool, 6 >::iterator mb6i
Definition: container_classes.h:1705
iterator ptr(size_type i)
Definition: container_classes.h:1961
const size_t * p_st
Definition: container_classes.h:728
size_t size_type
Definition: container_classes.h:278
T ****** p_ptr6
Definition: container_classes.h:926
~multi_geom()
Definition: container_classes.h:313
const multi_arr & operator=(const multi_arr &m)
Definition: container_classes.h:1016
pointer ptr0()
Definition: container_classes.h:2030
multi_arr< long, 4 >::iterator ml4i
Definition: container_classes.h:1712
const const_pntr operator+(const ptrdiff_t n) const
Definition: container_classes.h:182
iterator p_iterator(size_type i) const
Definition: container_classes.h:1915
size_type s[d]
allocated size (number of data elements, pointers are not counted)
Definition: container_classes.h:283
const pntr operator+(const ptrdiff_t n) const
Definition: container_classes.h:135
const size_t * p_st
Definition: container_classes.h:585
T & operator*() const
Definition: container_classes.h:98
T * p_ptr_alloc
Definition: container_classes.h:1754