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