Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JArray.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JARRAY__
2 #define __JTOOLS__JARRAY__
3 
4 #include <iterator>
5 #include <algorithm>
6 
7 #include "JIO/JSerialisable.hh"
8 #include "JTools/JMultiKey.hh"
9 #include "JMath/JMath.hh"
10 #include "JLang/JAssert.hh"
11 #include "JLang/JClass.hh"
12 #include "JLang/JException.hh"
13 #include "JLang/JEquals.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JTOOLS {}
21 namespace JPP { using namespace JTOOLS; }
22 
23 namespace JTOOLS {
24 
25  using JIO::JReader;
26  using JIO::JWriter;
27  using JMATH::JMath;
28  using JLANG::JEquals;
30 
31 
32  /**
33  * One dimensional array of template objects with fixed length.\n
34  * The internal data structure consists of a standard C-array.
35  */
36  template<unsigned int N, class T>
37  class JArray :
38  public JMath < JArray<N,T> >,
39  public JEquals< JArray<N,T> >
40  {
41  public:
42 
43  typedef const T* const_pointer;
44  typedef T* pointer;
45  typedef const T* const_iterator;
46  typedef T* iterator;
47  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
48  typedef std::reverse_iterator<iterator> reverse_iterator;
49  typedef T& reference;
50  typedef const T& const_reference;
51  typedef unsigned int size_type;
53 
54 
55  /**
56  * Default constructor.
57  */
59  {}
60 
61 
62  /**
63  * Copy constructor.
64  *
65  * \param array array
66  */
67  template<unsigned int M>
68  JArray(const JArray<M, T>& array)
69  {
70  STATIC_CHECK(M >= N);
71 
72  std::copy_n(array.data(), N, this->data());
73  }
74 
75 
76  /**
77  * Copy constructor.
78  *
79  * \param array array
80  */
81  template<unsigned int M>
82  JArray(const JArray<M, const T>& array)
83  {
84  STATIC_CHECK(M >= N);
85 
86  std::copy_n(array.data(), N, this->data());
87  }
88 
89 
90  /**
91  * Copy constructor.
92  *
93  * \param p pointer to data
94  */
95  JArray(const T* p)
96  {
97  std::copy_n(p, N, this->data());
98  }
99 
100 
101  /**
102  * Copy constructor.
103  *
104  * \param key multi-dimensional key
105  */
107  {
108  assign(key);
109  }
110 
111 
112  /**
113  * Copy constructor.
114  *
115  * \param key multi-dimensional key
116  */
118  {
119  assign(key);
120  }
121 
122 
123  /**
124  * Append constructor.
125  *
126  * \param array array
127  * \param value value
128  */
129  JArray(const JArray<N-1, T>& array, argument_type value)
130  {
131  std::copy_n(array.data(), N-1, this->data());
132 
133  this->buffer[N-1] = value;
134  }
135 
136 
137  /**
138  * Append constructor.
139  *
140  * \param array array
141  * \param value value
142  */
144  {
145  std::copy_n(array.data(), N-1, this->data());
146 
147  this->buffer[N-1] = value;
148  }
149 
150 
151  /**
152  * Append constructor.
153  *
154  * \param key multi-dimensional key
155  * \param value value
156  */
158  {
159  assign(key, value);
160  }
161 
162 
163  /**
164  * Append constructor.
165  *
166  * \param key multi-dimensional key
167  * \param value value
168  */
170  {
171  assign(key, value);
172  }
173 
174 
175  /**
176  * Initialise constructor.
177  *
178  * \param args values
179  */
180  template<class ...Args>
181  JArray(const Args& ...args)
182  {
183  set(args...);
184  }
185 
186 
187  /**
188  * Set array.
189  *
190  * \param args values
191  */
192  template<class ...Args>
193  JArray& set(const Args& ...args)
194  {
195  STATIC_CHECK(N == sizeof...(Args));
196 
197  __set__(0, args...);
198 
199  return *this;
200  }
201 
202 
203  const_iterator begin() const { return buffer; } //!< get iterator to begin of data
204  const_iterator end() const { return buffer + N; } //!< get iterator to end of data
205 
206 
207  iterator begin() { return buffer; } //!< get iterator to begin of data
208  iterator end() { return buffer + N; } //!< get iterator to end of data
209 
210 
211  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } //!< get reverse iterator to begin of data
212  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } //!< get reverse iterator to begin of data
213 
214 
215  reverse_iterator rbegin() { return reverse_iterator(end()); } //!< get reverse iterator to begin of data
216  reverse_iterator rend() { return reverse_iterator(begin()); } //!< get reverse iterator to end of data
217 
218 
219  /**
220  * Get element at given index.
221  *
222  * \param index index
223  * \return element
224  */
225  const_reference operator[](int index) const
226  {
227  return buffer[index];
228  }
229 
230 
231  /**
232  * Get element at given index.
233  *
234  * \param index index
235  * \return element
236  */
238  {
239  return buffer[index];
240  }
241 
242 
243  /**
244  * Get element at given index.
245  *
246  * \param index index
247  * \return element at index
248  */
249  const_reference at(int index) const
250  {
251  if (index >= 0 && index < N)
252  return buffer[index];
253  else
254  throw JIndexOutOfRange("JArray<>::at()");
255  }
256 
257 
258  /**
259  * Get element at given index.
260  *
261  * \param index index
262  * \return element at index
263  */
264  reference at(int index)
265  {
266  if (index >= 0 && index < N)
267  return buffer[index];
268  else
269  throw JIndexOutOfRange("JArray<>::at()");
270  }
271 
272 
273  /**
274  * Get pointer to data.
275  *
276  * \return pointer to data
277  */
279  {
280  return buffer;
281  }
282 
283 
284  /**
285  * Get pointer to data.
286  *
287  * \return pointer to data
288  */
290  {
291  return buffer;
292  }
293 
294 
295  /**
296  * Get size of data.
297  *
298  * \return size of data
299  */
300  static size_type size()
301  {
302  return N;
303  }
304 
305 
306  /**
307  * Make a copy in which the first element is removed.
308  *
309  * \return array
310  */
311  JArray<N-1, T> pop_front() const
312  {
313  return JArray<N-1, T>(&buffer[1]);
314  }
315 
316 
317  /**
318  * Make a copy in which the last element is removed.
319  *
320  * \return array
321  */
322  JArray<N-1, T> pop_back() const
323  {
324  return JArray<N-1, T>(buffer);
325  }
326 
327 
328  /**
329  * Negate array.
330  *
331  * \return this array
332  */
334  {
335  for (int i = 0; i != N; ++i) {
336  buffer[i] = -buffer[i];
337  }
338 
339  return *this;
340  }
341 
342 
343  /**
344  * Add array.
345  *
346  * \param array array
347  * \return this array
348  */
349  JArray& add(const JArray& array)
350  {
351  for (int i = 0; i != N; ++i) {
352  buffer[i] += array[i];
353  }
354 
355  return *this;
356  }
357 
358 
359  /**
360  * Subtract array.
361  *
362  * \param array array
363  * \return this array
364  */
365  JArray& sub(const JArray& array)
366  {
367  for (int i = 0; i != N; ++i) {
368  buffer[i] -= array[i];
369  }
370 
371  return *this;
372  }
373 
374 
375  /**
376  * Scale array.
377  *
378  * \param factor multiplication factor
379  * \return this array
380  */
381  JArray& mul(const double factor)
382  {
383  for (int i = 0; i != N; ++i) {
384  buffer[i] *= factor;
385  }
386 
387  return *this;
388  }
389 
390 
391  /**
392  * Scale array.
393  *
394  * \param factor division factor
395  * \return this array
396  */
397  JArray& div(const double factor)
398  {
399  for (int i = 0; i != N; ++i) {
400  buffer[i] /= factor;
401  }
402 
403  return *this;
404  }
405 
406 
407  /**
408  * Check equality.
409  *
410  * \param array array
411  * \return true if arrays are equal; else false
412  */
413  bool equals(const JArray<N, T>& array) const
414  {
415  for (int i = 0; i != N; ++i) {
416  if (buffer[i] != array[i]) {
417  return false;
418  }
419  }
420 
421  return true;
422  }
423 
424 
425  /**
426  * Read array from input.
427  *
428  * \param in reader
429  * \param buffer array
430  * \return reader
431  */
433  {
434  for (iterator i = buffer.begin(); i != buffer.end(); ++i) {
435  in >> *i;
436  }
437 
438  return in;
439  }
440 
441 
442  /**
443  * Write array to output.
444  *
445  * \param out writer
446  * \param buffer array
447  * \return writer
448  */
449  friend inline JWriter& operator<<(JWriter& out, const JArray& buffer)
450  {
451  for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
452  out << *i;
453  }
454 
455  return out;
456  }
457 
458  protected:
459 
461 
462 
463  /**
464  * Recursive method for setting array.
465  *
466  * \param i index
467  * \param x value at given index
468  * \param args remaining values
469  */
470  template<class ...Args>
471  void __set__(const int i, const argument_type x, const Args& ...args)
472  {
473  this->buffer[i] = x;
474 
475  __set__(i + 1, args...);
476  }
477 
478 
479  /**
480  * Termination method for setting array.
481  *
482  * \param i index
483  */
484  void __set__(const int i) const
485  {}
486 
487 
488  /**
489  * Recursive method for setting array.
490  *
491  * \param key multi-dimensional key
492  */
493  template<unsigned int M>
494  void assign(const JMultiKey<M, T>& key)
495  {
496  buffer[N-M] = key.first;
497 
498  assign(key.second);
499  }
500 
501 
502  /**
503  * Recursive method for setting array.
504  *
505  * \param key multi-dimensional key
506  */
507  template<unsigned int M>
508  void assign(const JMultiKey<M, const T>& key)
509  {
510  buffer[N-M] = key.first;
511 
512  assign(key.second);
513  }
514 
515 
516  /**
517  * Termination method for setting array.
518  *
519  * \param key one-dimensional key
520  */
521  void assign(const JMultiKey<1, T>& key)
522  {
523  buffer[N-1] = key.first;
524  }
525 
526 
527  /**
528  * Termination method for setting array.
529  *
530  * \param key one-dimensional key
531  */
532  void assign(const JMultiKey<1, const T>& key)
533  {
534  buffer[N-1] = key.first;
535  }
536 
537 
538  /**
539  * Recursive method for setting array.
540  *
541  * \param key multi-dimensional key
542  * \param value value
543  */
544  template<unsigned int M>
545  void assign(const JMultiKey<M, T>& key, argument_type value)
546  {
547  buffer[N-M-1] = key.first;
548 
549  assign(key.second, value);
550  }
551 
552 
553  /**
554  * Recursive method for setting array.
555  *
556  * \param key multi-dimensional key
557  * \param value value
558  */
559  template<unsigned int M>
561  {
562  buffer[N-M-1] = key.first;
563 
564  assign(key.second, value);
565  }
566 
567 
568  /**
569  * Termination method for setting array.
570  *
571  * \param key one-dimensional key
572  * \param value value
573  */
574  void assign(const JMultiKey<1, T>& key, argument_type value)
575  {
576  buffer[N-2] = key.first;
577  buffer[N-1] = value;
578  }
579 
580 
581  /**
582  * Termination method for setting array.
583  *
584  * \param key one-dimensional key
585  * \param value value
586  */
588  {
589  buffer[N-2] = key.first;
590  buffer[N-1] = value;
591  }
592  };
593 
594 
595  /**
596  * One dimensional array of template objects with fixed length.
597  * The internal data structure consists of a standard C-array.
598  */
599  template<class T>
600  class JArray<1, T> :
601  public JMath < JArray<1,T> >,
602  public JEquals< JArray<1,T> >
603  {
604  public:
605 
606  static const unsigned int N = 1;
607 
608  typedef const T* const_pointer;
609  typedef T* pointer;
610  typedef const T* const_iterator;
611  typedef T* iterator;
612  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
613  typedef std::reverse_iterator<iterator> reverse_iterator;
614  typedef T& reference;
615  typedef const T& const_reference;
616  typedef unsigned int size_type;
618 
619 
620  /**
621  * Default constructor.
622  */
624  {}
625 
626 
627  /**
628  * Copy constructor.
629  *
630  * \param array array
631  */
632  template<unsigned int M>
633  JArray(const JArray<M, T>& array)
634  {
635  buffer[0] = array[0];
636  }
637 
638 
639  /**
640  * Copy constructor.
641  *
642  * \param array array
643  */
644  template<unsigned int M>
646  {
647  buffer[0] = array[0];
648  }
649 
650 
651  /**
652  * Copy constructor.
653  *
654  * \param p pointer to data
655  */
656  JArray(const T* p)
657  {
658  buffer[0] = p[0];
659  }
660 
661 
662  /**
663  * Copy constructor.
664  *
665  * \param key multi-dimensional key
666  */
668  {
669  buffer[0] = key.first;
670  }
671 
672 
673  /**
674  * Copy constructor.
675  *
676  * \param key multi-dimensional key
677  */
679  {
680  buffer[0] = key.first;
681  }
682 
683 
684  /**
685  * Initialise constructor.
686  *
687  * \param x value;
688  */
690  {
691  buffer[0] = x;
692  }
693 
694 
695  const_iterator begin() const { return buffer; } //!< get iterator to begin of data
696  const_iterator end() const { return buffer + N; } //!< get iterator to end of data
697 
698 
699  iterator begin() { return buffer; } //!< get iterator to begin of data
700  iterator end() { return buffer + N; } //!< get iterator to end of data
701 
702 
703  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } //!< get reverse iterator to begin of data
704  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } //!< get reverse iterator to begin of data
705 
706 
707  reverse_iterator rbegin() { return reverse_iterator(end()); } //!< get reverse iterator to begin of data
708  reverse_iterator rend() { return reverse_iterator(begin()); } //!< get reverse iterator to end of data
709 
710 
711  /**
712  * Get element at given index.
713  *
714  * \param index index
715  * \return element
716  */
717  const_reference operator[](int index) const
718  {
719  return buffer[index];
720  }
721 
722 
723  /**
724  * Get element at given index.
725  *
726  * \param index index
727  * \return element
728  */
730  {
731  return buffer[index];
732  }
733 
734 
735  /**
736  * Get element at given index.
737  *
738  * \param index index
739  * \return element at index
740  */
741  const_reference at(int index) const
742  {
743  if (index >= 0 && index < N)
744  return buffer[index];
745  else
746  throw JIndexOutOfRange("JArray<>::at()");
747  }
748 
749 
750  /**
751  * Get element at given index.
752  *
753  * \param index index
754  * \return element at index
755  */
756  reference at(int index)
757  {
758  if (index >= 0 && index < N)
759  return buffer[index];
760  else
761  throw JIndexOutOfRange("JArray<>::at()");
762  }
763 
764 
765  /**
766  * Get pointer to data.
767  *
768  * \return pointer to data
769  */
771  {
772  return buffer;
773  }
774 
775 
776  /**
777  * Get pointer to data.
778  *
779  * \return pointer to data
780  */
782  {
783  return buffer;
784  }
785 
786 
787  /**
788  * Get size of data.
789  *
790  * \return size of data
791  */
792  static size_type size()
793  {
794  return N;
795  }
796 
797 
798  /**
799  * Negate array.
800  *
801  * \return this array
802  */
804  {
805  buffer[0] = -buffer[0];
806 
807  return *this;
808  }
809 
810 
811  /**
812  * Add array.
813  *
814  * \param array array
815  * \return this array
816  */
817  JArray& add(const JArray& array)
818  {
819  buffer[0] += array[0];
820 
821  return *this;
822  }
823 
824 
825  /**
826  * Subtract array.
827  *
828  * \param array array
829  * \return this array
830  */
831  JArray& sub(const JArray& array)
832  {
833  buffer[0] -= array[0];
834 
835  return *this;
836  }
837 
838 
839  /**
840  * Scale array.
841  *
842  * \param factor multiplication factor
843  * \return this array
844  */
845  JArray& mul(const double factor)
846  {
847  buffer[0] *= factor;
848 
849  return *this;
850  }
851 
852 
853  /**
854  * Scale array.
855  *
856  * \param factor division factor
857  * \return this array
858  */
859  JArray& div(const double factor)
860  {
861  buffer[0] /= factor;
862 
863  return *this;
864  }
865 
866 
867  /**
868  * Check equality.
869  *
870  * \param array array
871  * \return true if arrays are equal; else false
872  */
873  bool equals(const JArray<N, T>& array) const
874  {
875  return buffer[0] == array[0];
876  }
877 
878 
879  /**
880  * Read array from input.
881  *
882  * \param in reader
883  * \param buffer array
884  * \return reader
885  */
887  {
888  return in >> buffer[0];
889  }
890 
891 
892  /**
893  * Write array to output.
894  *
895  * \param out writer
896  * \param buffer array
897  * \return writer
898  */
899  friend inline JWriter& operator<<(JWriter& out, const JArray& buffer)
900  {
901  return out << buffer[0];
902  }
903 
904  protected:
905  T buffer[1];
906  };
907 
908 
909  /**
910  * One dimensional read-only array of template objects with fixed length.
911  * The internal data structure consists of a simple C-pointer to the actual data.
912  * The user should ensure that the data are persistent.
913  */
914  template<unsigned int N, class T>
915  class JArray<N, const T> {
916  public:
917 
918  friend class JArray<N + 1, const T>;
919 
920  typedef const T* const_pointer;
921  typedef const T* const_iterator;
922  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
923  typedef const T& const_reference;
924  typedef unsigned int size_type;
925 
926 
927  /**
928  * Copy constructor.
929  *
930  * \param array array
931  */
932  template<unsigned int M>
933  JArray(const JArray<M, T>& array) :
934  p(array.data())
935  {
936  STATIC_CHECK(M >= N);
937  }
938 
939 
940  /**
941  * Copy constructor.
942  *
943  * \param array array
944  */
945  template<unsigned int M>
946  JArray(const JArray<M, const T>& array) :
947  p(array.data())
948  {
949  STATIC_CHECK(M >= N);
950  }
951 
952 
953  const_iterator begin() const { return p; } //!< get iterator to begin of data
954  const_iterator end() const { return p + N; } //!< get iterator to end of data
955 
956 
957  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } //!< get reverse iterator to begin of data
958  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } //!< get reverse iterator to end of data
959 
960 
961  /**
962  * Get element at given index.
963  *
964  * \param index index
965  * \return element at index
966  */
967  const_reference operator[](int index) const
968  {
969  return p[index];
970  }
971 
972 
973  /**
974  * Get element at given index.
975  *
976  * \param index index
977  * \return element at index
978  */
979  const_reference at(int index) const
980  {
981  if (index >= 0 && index < N)
982  return p[index];
983  else
984  throw JIndexOutOfRange("JArray<>::at()");
985  }
986 
987 
988  /**
989  * Get pointer to data.
990  *
991  * \return pointer to data
992  */
994  {
995  return p;
996  }
997 
998 
999  /**
1000  * Get size of data.
1001  *
1002  * \return size of data
1003  */
1004  static size_type size()
1005  {
1006  return N;
1007  }
1008 
1009 
1010  /**
1011  * Make a copy in which the first element is removed.
1012  *
1013  * \return array
1014  */
1015  JArray<N-1, const T> pop_front() const
1016  {
1017  return JArray<N-1, const T>(p + 1);
1018  }
1019 
1020 
1021  /**
1022  * Make a copy in which the last element is removed.
1023  *
1024  * \return array
1025  */
1026  JArray<N-1, const T> pop_back() const
1027  {
1028  return JArray<N-1, const T>(p);
1029  }
1030 
1031 
1032  /**
1033  * Write array to output.
1034  *
1035  * \param out writer
1036  * \param buffer array
1037  * \return writer
1038  */
1039  friend inline JWriter& operator<<(JWriter& out, const JArray& buffer)
1040  {
1041  for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
1042  out << *i;
1043  }
1044 
1045  return out;
1046  }
1047 
1048  protected:
1049 
1051 
1052  /**
1053  * Constructor.
1054  *
1055  * \param __p pointer to data
1056  */
1057  JArray(const T* __p) :
1058  p(__p)
1059  {}
1060  };
1061 
1062 
1063  /**
1064  * One dimensional read-only array of template objects with fixed length.
1065  * The internal data structure consists of a simple C-pointer to the actual data.
1066  * The user should ensure that the data are persistent.
1067  */
1068  template<class T>
1069  class JArray<1, const T> {
1070  public:
1071 
1072  static const unsigned int N = 1;
1073 
1074  friend class JArray<N + 1, const T>;
1075 
1076  typedef const T* const_pointer;
1077  typedef const T* const_iterator;
1078  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
1079  typedef const T& const_reference;
1080  typedef unsigned int size_type;
1081 
1082 
1083  /**
1084  * Copy constructor.
1085  *
1086  * \param array array
1087  */
1088  template<unsigned int M>
1089  JArray(const JArray<M, T>& array) :
1090  p(array.data())
1091  {
1092  STATIC_CHECK(M >= N);
1093  }
1094 
1095 
1096  /**
1097  * Copy constructor.
1098  *
1099  * \param array array
1100  */
1101  template<unsigned int M>
1102  JArray(const JArray<M, const T>& array) :
1103  p(array.data())
1104  {
1105  STATIC_CHECK(M >= N);
1106  }
1107 
1108 
1109  const_iterator begin() const { return p; } //!< get iterator to begin of data
1110  const_iterator end() const { return p + N; } //!< get iterator to end of data
1111 
1112 
1113  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } //!< get reverse iterator to begin of data
1114  const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } //!< get reverse iterator to end of data
1115 
1116 
1117  /**
1118  * Get element at given index.
1119  *
1120  * \param index index
1121  * \return element at index
1122  */
1123  const_reference operator[](int index) const
1124  {
1125  return p[index];
1126  }
1127 
1128 
1129  /**
1130  * Get element at given index.
1131  *
1132  * \param index index
1133  * \return element at index
1134  */
1135  const_reference at(int index) const
1136  {
1137  if (index >= 0 && index < N)
1138  return p[index];
1139  else
1140  throw JIndexOutOfRange("JArray<>::at()");
1141  }
1142 
1143 
1144  /**
1145  * Get pointer to data.
1146  *
1147  * \return pointer to data
1148  */
1150  {
1151  return p;
1152  }
1153 
1154 
1155  /**
1156  * Get size of data.
1157  *
1158  * \return size of data
1159  */
1160  static size_type size()
1161  {
1162  return N;
1163  }
1164 
1165 
1166  /**
1167  * Write array to output.
1168  *
1169  * \param out writer
1170  * \param buffer array
1171  * \return writer
1172  */
1173  friend inline JWriter& operator<<(JWriter& out, const JArray& buffer)
1174  {
1175  return out << buffer[0];
1176  }
1177 
1178  protected:
1179 
1181 
1182  /**
1183  * Constructor.
1184  *
1185  * \param __p pointer to data
1186  */
1187  JArray(const T* __p) :
1188  p(__p)
1189  {}
1190  };
1191 }
1192 
1193 #endif
const_reverse_iterator rbegin() const
get reverse iterator to begin of data
Definition: JArray.hh:957
JArray & sub(const JArray &array)
Subtract array.
Definition: JArray.hh:831
const T * const_iterator
Definition: JArray.hh:610
const T * const_pointer
Definition: JArray.hh:43
const_reverse_iterator rend() const
get reverse iterator to begin of data
Definition: JArray.hh:212
Exceptions.
JArray(const T *__p)
Constructor.
Definition: JArray.hh:1187
Interface for binary output.
JArray(const JMultiKey< N-1, T > &key, argument_type value)
Append constructor.
Definition: JArray.hh:157
JArray & div(const double factor)
Scale array.
Definition: JArray.hh:397
JArray & div(const double factor)
Scale array.
Definition: JArray.hh:859
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:110
JArray(const JArray< N-1, T > &array, argument_type value)
Append constructor.
Definition: JArray.hh:129
static size_type size()
Get size of data.
Definition: JArray.hh:1160
do $JPP JMEstimator M
Definition: JMEstimator.sh:37
JArray(const JArray< M, const T > &array)
Copy constructor.
Definition: JArray.hh:1102
JArray(argument_type x)
Initialise constructor.
Definition: JArray.hh:689
static size_type size()
Get size of data.
Definition: JArray.hh:300
friend JWriter & operator<<(JWriter &out, const JArray &buffer)
Write array to output.
Definition: JArray.hh:449
void __set__(const int i, const argument_type x, const Args &...args)
Recursive method for setting array.
Definition: JArray.hh:471
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:203
const_reference operator[](int index) const
Get element at given index.
Definition: JArray.hh:225
reference at(int index)
Get element at given index.
Definition: JArray.hh:264
pointer data()
Get pointer to data.
Definition: JArray.hh:289
const_reverse_iterator rend() const
get reverse iterator to end of data
Definition: JArray.hh:958
friend JReader & operator>>(JReader &in, JArray &buffer)
Read array from input.
Definition: JArray.hh:432
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:1149
reference operator[](int index)
Get element at given index.
Definition: JArray.hh:237
void assign(const JMultiKey< M, T > &key, argument_type value)
Recursive method for setting array.
Definition: JArray.hh:545
pointer data()
Get pointer to data.
Definition: JArray.hh:781
T & reference
Definition: JArray.hh:49
void assign(const JMultiKey< 1, T > &key, argument_type value)
Termination method for setting array.
Definition: JArray.hh:574
reference at(int index)
Get element at given index.
Definition: JArray.hh:756
JArray & mul(const double factor)
Scale array.
Definition: JArray.hh:381
const_reverse_iterator rend() const
get reverse iterator to end of data
Definition: JArray.hh:1114
JArray< N-1, T > pop_front() const
Make a copy in which the first element is removed.
Definition: JArray.hh:311
JArray & add(const JArray &array)
Add array.
Definition: JArray.hh:349
iterator begin()
get iterator to begin of data
Definition: JArray.hh:207
friend JReader & operator>>(JReader &in, JArray &buffer)
Read array from input.
Definition: JArray.hh:886
JLANG::JClass< T >::argument_type argument_type
Definition: JArray.hh:617
const_reverse_iterator rbegin() const
get reverse iterator to begin of data
Definition: JArray.hh:1113
JArray & set(const Args &...args)
Set array.
Definition: JArray.hh:193
JArray & negate()
Negate array.
Definition: JArray.hh:803
JArray & sub(const JArray &array)
Subtract array.
Definition: JArray.hh:365
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: JArray.hh:1078
JArray()
Default constructor.
Definition: JArray.hh:58
friend JWriter & operator<<(JWriter &out, const JArray &buffer)
Write array to output.
Definition: JArray.hh:1039
JArray(const JArray< M, T > &array)
Copy constructor.
Definition: JArray.hh:68
const_reference operator[](int index) const
Get element at given index.
Definition: JArray.hh:1123
iterator begin()
get iterator to begin of data
Definition: JArray.hh:699
Multidimensional key.
Definition: JMultiKey.hh:34
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:993
const T * const_pointer
Definition: JArray.hh:608
JArray(const Args &...args)
Initialise constructor.
Definition: JArray.hh:181
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JArray & negate()
Negate array.
Definition: JArray.hh:333
void assign(const JMultiKey< 1, T > &key)
Termination method for setting array.
Definition: JArray.hh:521
const_reference at(int index) const
Get element at given index.
Definition: JArray.hh:979
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:1109
void assign(const JMultiKey< 1, const T > &key)
Termination method for setting array.
Definition: JArray.hh:532
const_reference at(int index) const
Get element at given index.
Definition: JArray.hh:1135
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:695
void assign(const JMultiKey< 1, const T > &key, argument_type value)
Termination method for setting array.
Definition: JArray.hh:587
reference operator[](int index)
Get element at given index.
Definition: JArray.hh:729
iterator end()
get iterator to end of data
Definition: JArray.hh:700
JArray(const T *__p)
Constructor.
Definition: JArray.hh:1057
const_iterator end() const
get iterator to end of data
Definition: JArray.hh:954
JArray & add(const JArray &array)
Add array.
Definition: JArray.hh:817
do set_variable OUTPUT_DIRECTORY $WORKDIR T
const_reference operator[](int index) const
Get element at given index.
Definition: JArray.hh:967
static size_type size()
Get size of data.
Definition: JArray.hh:1004
const_iterator end() const
get iterator to end of data
Definition: JArray.hh:696
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
std::reverse_iterator< iterator > reverse_iterator
Definition: JArray.hh:48
friend JWriter & operator<<(JWriter &out, const JArray &buffer)
Write array to output.
Definition: JArray.hh:1173
const_iterator end() const
get iterator to end of data
Definition: JArray.hh:204
JArray(const JArray< M, const T > &array)
Copy constructor.
Definition: JArray.hh:946
unsigned int size_type
Definition: JArray.hh:616
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: JArray.hh:922
JArray(const JMultiKey< N, const T > &key)
Copy constructor.
Definition: JArray.hh:117
void assign(const JMultiKey< M, const T > &key, argument_type value)
Recursive method for setting array.
Definition: JArray.hh:560
void __set__(const int i) const
Termination method for setting array.
Definition: JArray.hh:484
Interface for binary input.
const_iterator begin() const
get iterator to begin of data
Definition: JArray.hh:953
JArray< N-1, T > pop_back() const
Make a copy in which the last element is removed.
Definition: JArray.hh:322
One dimensional array of template objects with fixed length.
Definition: JArray.hh:37
reverse_iterator rend()
get reverse iterator to end of data
Definition: JArray.hh:216
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: JArray.hh:47
const_reference at(int index) const
Get element at given index.
Definition: JArray.hh:741
const_reference at(int index) const
Get element at given index.
Definition: JArray.hh:249
JArray(const JArray< M, const T > &array)
Copy constructor.
Definition: JArray.hh:82
JArray()
Default constructor.
Definition: JArray.hh:623
const_iterator end() const
get iterator to end of data
Definition: JArray.hh:1110
const_reverse_iterator rbegin() const
get reverse iterator to begin of data
Definition: JArray.hh:703
const_reference operator[](int index) const
Get element at given index.
Definition: JArray.hh:717
JArray(const JArray< M, T > &array)
Copy constructor.
Definition: JArray.hh:933
JArray(const JMultiKey< 1, const T > &key)
Copy constructor.
Definition: JArray.hh:678
unsigned int size_type
Definition: JArray.hh:51
const_reverse_iterator rbegin() const
get reverse iterator to begin of data
Definition: JArray.hh:211
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: JArray.hh:612
#define STATIC_CHECK(expr)
Definition: JAssert.hh:29
JArray(const JArray< M, T > &array)
Copy constructor.
Definition: JArray.hh:633
JArray(const T *p)
Copy constructor.
Definition: JArray.hh:656
JArray< N-1, const T > pop_back() const
Make a copy in which the last element is removed.
Definition: JArray.hh:1026
JArray(const T *p)
Copy constructor.
Definition: JArray.hh:95
T * iterator
Definition: JArray.hh:46
JArray(const JArray< M, T > &array)
Copy constructor.
Definition: JArray.hh:1089
bool equals(const JArray< N, T > &array) const
Check equality.
Definition: JArray.hh:413
void assign(const JMultiKey< M, T > &key)
Recursive method for setting array.
Definition: JArray.hh:494
reverse_iterator rend()
get reverse iterator to end of data
Definition: JArray.hh:708
JArray & mul(const double factor)
Scale array.
Definition: JArray.hh:845
JLANG::JClass< T >::argument_type argument_type
Definition: JArray.hh:52
JArray< N-1, const T > pop_front() const
Make a copy in which the first element is removed.
Definition: JArray.hh:1015
Base class for data structures with artithmetic capabilities.
const T & const_reference
Definition: JArray.hh:615
bool equals(const JArray< N, T > &array) const
Check equality.
Definition: JArray.hh:873
const T & const_reference
Definition: JArray.hh:50
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:770
JArray(const JMultiKey< N, T > &key)
Copy constructor.
Definition: JArray.hh:106
static size_type size()
Get size of data.
Definition: JArray.hh:792
JArray(const JArray< M, const T > &array)
Copy constructor.
Definition: JArray.hh:645
iterator end()
get iterator to end of data
Definition: JArray.hh:208
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
reverse_iterator rbegin()
get reverse iterator to begin of data
Definition: JArray.hh:215
void assign(const JMultiKey< M, const T > &key)
Recursive method for setting array.
Definition: JArray.hh:508
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
JArray(const JMultiKey< N-1, const T > &key, argument_type value)
Append constructor.
Definition: JArray.hh:169
JArray(const JMultiKey< 1, T > &key)
Copy constructor.
Definition: JArray.hh:667
const_pointer data() const
Get pointer to data.
Definition: JArray.hh:278
reverse_iterator rbegin()
get reverse iterator to begin of data
Definition: JArray.hh:707
const T * const_iterator
Definition: JArray.hh:45
const_reverse_iterator rend() const
get reverse iterator to begin of data
Definition: JArray.hh:704
std::reverse_iterator< iterator > reverse_iterator
Definition: JArray.hh:613
JArray(const JArray< N-1, const T > &array, argument_type value)
Append constructor.
Definition: JArray.hh:143
friend JWriter & operator<<(JWriter &out, const JArray &buffer)
Write array to output.
Definition: JArray.hh:899