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