Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMultiMap.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JMULTIMAP__
2 #define __JTOOLS__JMULTIMAP__
3 
4 #include "JLang/JEquals.hh"
6 
7 #include "JMath/JMath.hh"
8 
9 #include "JTools/JDistance.hh"
10 #include "JTools/JPair.hh"
11 #include "JTools/JMultiPair.hh"
12 #include "JTools/JMapList.hh"
14 #include "JTools/JMultiKey.hh"
15 
16 
17 /**
18  * \file
19  *
20  * General purpose multidimensional map based on a type list of maps.
21  * \author mdejong
22  */
23 namespace JTOOLS {}
24 namespace JPP { using namespace JTOOLS; }
25 
26 namespace JTOOLS {
27 
28  using JMATH::JMath;
29  using JLANG::JEquals;
31 
32 
33  /**
34  * Multidimensional map.
35  *
36  * The first template parameter refers to the data type of the (multidimensional) key;
37  * the second to the data type of the overall mapped value;
38  * the third to the list of maps used; and
39  * the fourth to the distance operator.
40  *
41  * In addition to the standard STL iterators,
42  * there are super iteretors for linear access to the multidimensional map.\n
43  * The access from a super iterator to the actual elements in the multidimensional map
44  * is handled via the usual dereference and pointer operators.\n
45  * The multidimensional key (see JTOOLS::JMultiKey) and value can directly be obtained
46  * via member methods <tt>%getKey()</tt> and <tt>%getValue()</tt>, respectively.
47  */
48  template<class JAbscissa_t,
49  class JOrdinate_t,
50  class JMaplist_t,
51  class JDistance_t = JDistance<JAbscissa_t> >
52  class JMultiMap;
53 
54 
55  /**
56  * Template specialisation of JMultiMap for map list with at least one map.
57  */
58  template<class JAbscissa_t,
59  class JOrdinate_t,
60  template<class, class, class> class JHead_t,
61  class JTail_t,
62  class JDistance_t>
63  class JMultiMap<JAbscissa_t, JOrdinate_t, JMapList<JHead_t, JTail_t>, JDistance_t> :
64  public JHead_t<JAbscissa_t, JMultiMap<JAbscissa_t, JOrdinate_t, JTail_t, JDistance_t>, JDistance_t>,
65  public JMath< JMultiMap<JAbscissa_t, JOrdinate_t, JMapList<JHead_t, JTail_t>, JDistance_t> >
66  {
67  public:
68 
69  enum { NUMBER_OF_DIMENSIONS = JMapLength< JMapList<JHead_t, JTail_t> >::value };
70 
71  typedef JHead_t<JAbscissa_t,
73  JDistance_t> map_type;
74 
75  typedef JAbscissa_t abscissa_type;
76  typedef JOrdinate_t ordinate_type;
77 
78  typedef typename map_type::key_type key_type;
79  typedef typename map_type::mapped_type mapped_type;
80  typedef typename map_type::value_type value_type;
81 
82  typedef typename map_type::const_iterator const_iterator;
83  typedef typename map_type::const_reverse_iterator const_reverse_iterator;
84  typedef typename map_type::iterator iterator;
85  typedef typename map_type::reverse_iterator reverse_iterator;
86 
87  using map_type::insert;
88  using map_type::configure;
89  using map_type::get;
90 
91 
92  /**
93  * Default constructor.
94  */
96  {}
97 
98 
99  /**
100  * Add map.
101  *
102  * \param map multimap
103  * \return this multimap
104  */
106  {
107  static_cast<map_type&>(*this).add(static_cast<const map_type&>(map));
108 
109  return *this;
110  }
111 
112 
113  /**
114  * Subtract map.
115  *
116  * \param map multimap
117  * \return this multimap
118  */
120  {
121  static_cast<map_type&>(*this).sub(static_cast<const map_type&>(map));
122 
123  return *this;
124  }
125 
126 
127  /**
128  * Scale contents.
129  *
130  * \param value multiplication factor
131  * \return this multimap
132  */
133  JMultiMap& mul(const double value)
134  {
135  static_cast<map_type&>(*this).mul(value);
136 
137  return *this;
138  }
139 
140  /**
141  * Scale contents.
142  *
143  * \param value division factor
144  * \return this multimap
145  */
146  JMultiMap& div(const double value)
147  {
148  static_cast<map_type&>(*this).div(value);
149 
150  return *this;
151  }
152 
153 
154  /**
155  * Function application to each element of this multimap.
156  *
157  * \param function function
158  * \return function
159  */
160  template<class JFunction_t>
161  void for_each(const JFunction_t& function)
162  {
163  function(*this);
164 
165  for (iterator i = this->begin(); i != this->end(); ++i) {
166  i->getY().for_each(function);
167  }
168  }
169 
170 
171  /**
172  * Configure multidimensional map.
173  *
174  * \param bounds multidimensional bounds
175  */
177  {
178  this->configure(JMultiKey<0, abscissa_type>(), bounds);
179  }
180 
181 
182  /**
183  * Configure multidimensional map.
184  *
185  * \param key multidimensional key
186  * \param bounds multidimensional bounds
187  */
188  template<unsigned int N, unsigned int M>
190  {
191  this->configure(bounds(key));
192 
193  for (iterator i = this->begin(); i != this->end(); ++i) {
194  i->getY().configure(JMultiKey<M+1, abscissa_type>(key,i->getX()), bounds);
195  }
196  }
197 
198  private:
199 
200  /**
201  * Base class for multidimensional iterator.
202  */
203  template<class first_iterator, class second_iterator>
204  struct iterator_base :
205  public JEquals< iterator_base<first_iterator, second_iterator> >
206  {
208  typedef typename second_iterator::value_type value_type;
211 
212 
213  /**
214  * Auxiliary class for smart pointer.
215  */
216  struct pointer_type :
217  private JPair<const key_type, second_iterator&>
218  {
219  /**
220  * Constructor.
221  *
222  * \param key key
223  * \param value value
224  */
225  pointer_type(const key_type key, second_iterator& value) :
226  JPair<const key_type, second_iterator&>(key, value)
227  {}
228 
229 
230  /**
231  * Smart pointer operator.
232  *
233  * \return pointer to object
234  */
236  {
237  return this;
238  }
239  };
240 
241 
242  /**
243  * Smart pointer operator.
244  *
245  * \return pointer to pair of iterators
246  */
247  pointer_type operator->()
248  {
249  return pointer_type(i->getX(), second);
250  }
251 
252 
253  /**
254  * Dereference operator.
255  *
256  * \return multidimensional pair
257  */
259  {
260  return multipair_type(i->getX(), *second);
261  }
262 
263 
264  /**
265  * Equality of super iterator.
266  *
267  * \param cursor super iterator
268  * \return true if equal; else false
269  */
270  bool equals(const iterator_base& cursor) const
271  {
272  return i == cursor.i && (i == range.second || second.equals(cursor.second));
273  }
274 
275 
276  /**
277  * Get multidimensional key.
278  *
279  * \return key
280  */
282  {
283  return multikey_type(i->getX(), second.getKey());
284  }
285 
286 
287  /**
288  * Get value.
289  *
290  * \return value
291  */
293  {
294  return this->second.getValue();
295  }
296 
297 
298  protected:
300  first_iterator i;
301  second_iterator second;
302  };
303 
304 
305  /**
306  * Helper class for multidimensional iterator.
307  */
308  template<class first_iterator, class second_iterator>
309  struct iterator_helper :
310  public iterator_base<first_iterator, second_iterator>,
311  public JForwardIterator< iterator_helper<first_iterator, second_iterator> >
312  {
313  /**
314  * Default constructor.
315  */
317  {}
318 
319 
320  /**
321  * Constructor.
322  *
323  * \param __begin begin of data
324  * \param __end end of data
325  */
326  iterator_helper(first_iterator __begin,
327  first_iterator __end)
328  {
329  this->range = std::make_pair(__begin, __end);
330 
331  for (this->i = this->range.first; this->i != this->range.second; ++(this->i)) {
332 
333  this->second = this->i->getY().super_begin();
334 
335  if (this->second != this->i->getY().super_end()) {
336  break;
337  }
338  }
339  }
340 
341 
342  /**
343  * Increment super iterator.
344  *
345  * \return true if valid; else false
346  */
347  virtual bool increment() override
348  {
349  if (!this->second.increment()) {
350 
351  while (++(this->i) != this->range.second) {
352 
353  this->second = this->i->getY().super_begin();
354 
355  if (this->second != this->i->getY().super_end()) {
356  break;
357  }
358  }
359  }
360 
361  return this->i != this->range.second;
362  }
363  };
364 
365 
366  /**
367  * Helper class for multidimensional reverse iterator.
368  */
369  template<class first_iterator, class second_iterator>
370  struct reverse_iterator_helper :
371  public iterator_base<first_iterator, second_iterator>,
372  public JForwardIterator< reverse_iterator_helper<first_iterator, second_iterator> >
373  {
374  /**
375  * Default constructor.
376  */
378  {}
379 
380 
381  /**
382  * Constructor.
383  *
384  * \param __begin begin of data
385  * \param __end end of data
386  */
387  reverse_iterator_helper(first_iterator __begin,
388  first_iterator __end)
389  {
390  this->range = std::make_pair(__begin, __end);
391 
392  for (this->i = this->range.first; this->i != this->range.second; ++(this->i)) {
393 
394  this->second = this->i->getY().super_rbegin();
395 
396  if (this->second != this->i->getY().super_rend()) {
397  break;
398  }
399  }
400  }
401 
402 
403  /**
404  * Increment super iterator.
405  *
406  * \return true if valid; else false
407  */
408  virtual bool increment() override
409  {
410  if (!this->second.increment()) {
411 
412  while (++(this->i) != this->range.second) {
413 
414  this->second = this->i->getY().super_rbegin();
415 
416  if (this->second != this->i->getY().super_rend()) {
417  break;
418  }
419  }
420  }
421 
422  return this->i != this->range.second;
423  }
424  };
425 
426  public:
427 
428  class super_const_iterator; // forward declaration
429 
430 
431  /**
432  * Multidimensional iterator.
433  */
434  struct super_iterator :
435  public iterator_helper<iterator, typename mapped_type::super_iterator>
436  {
437 
438  friend class JMultiMap;
439  friend class super_const_iterator;
440 
441  /**
442  * Default constructor.
443  */
445  {}
446 
447  private:
448  /**
449  * Constructor.
450  *
451  * \param __begin begin of data
452  * \param __end end of data
453  */
455  iterator __end) :
456  iterator_helper<iterator, typename mapped_type::super_iterator>(__begin, __end)
457  {}
458  };
459 
460 
461  /**
462  * Multidimensional const_iterator.
463  */
464  struct super_const_iterator :
465  public iterator_helper<const_iterator, typename mapped_type::super_const_iterator>,
466  public JEquals<super_const_iterator, super_iterator>
467  {
468 
469  friend class JMultiMap;
470 
471  /**
472  * Default constructor.
473  */
475  {}
476 
477 
478  /**
479  * Copy constructor.
480  *
481  * \param cursor super iterator
482  */
483  super_const_iterator(const super_iterator& cursor)
484  {
485  this->range = cursor.range;
486  this->i = cursor.i;
487  this->second = cursor.second;
488  }
489 
490 
491  /**
492  * Equality of super iterator.
493  *
494  * \param cursor super iterator
495  * \return true if equal; else false
496  */
497  bool equals(const super_const_iterator& cursor) const
498  {
499  return static_cast<const iterator_base<const_iterator, typename mapped_type::super_const_iterator>&>(*this).equals(cursor);
500  }
501 
502 
503  /**
504  * Equality of super iterator.
505  *
506  * \param cursor super iterator
507  * \return true if equal; else false
508  */
509  bool equals(const super_iterator& cursor) const
510  {
511  return equals(super_const_iterator(cursor));
512  }
513 
514  private:
515  /**
516  * Constructor.
517  *
518  * \param __begin begin of data
519  * \param __end end of data
520  */
522  const_iterator __end) :
523  iterator_helper<const_iterator, typename mapped_type::super_const_iterator>(__begin, __end)
524  {}
525  };
526 
527 
528  class super_const_reverse_iterator; // forward declaration
529 
530 
531  /**
532  * Multidimensional reverse iterator.
533  */
534  struct super_reverse_iterator :
535  public reverse_iterator_helper<reverse_iterator, typename mapped_type::super_reverse_iterator>
536  {
537 
538  friend class JMultiMap;
539  friend class super_const_reverse_iterator;
540 
541  /**
542  * Default constructor.
543  */
545  {}
546 
547  private:
548  /**
549  * Constructor.
550  *
551  * \param __begin reverse begin of data
552  * \param __end reverse end of data
553  */
555  reverse_iterator __end) :
556  reverse_iterator_helper<reverse_iterator, typename mapped_type::super_reverse_iterator>(__begin, __end)
557  {}
558  };
559 
560 
561  /**
562  * Multidimensional const reverse iterator.
563  */
564  struct super_const_reverse_iterator :
565  public reverse_iterator_helper<const_reverse_iterator, typename mapped_type::super_const_reverse_iterator>,
566  public JEquals<super_const_reverse_iterator, super_reverse_iterator>
567  {
568 
569  friend class JMultiMap;
570 
571  /**
572  * Default constructor.
573  */
575  {}
576 
577 
578  /**
579  * Copy constructor.
580  *
581  * \param cursor super reverse iterator
582  */
583  super_const_reverse_iterator(super_reverse_iterator cursor)
584  {
585  this->range = cursor.range;
586  this->i = cursor.i;
587  this->second = cursor.second;
588  }
589 
590 
591  /**
592  * Equality of super reverse iterator.
593  *
594  * \param cursor super reverse iterator
595  * \return true if equal; else false
596  */
597  bool equals(const super_const_reverse_iterator& cursor) const
598  {
599  return static_cast<const iterator_base<const_reverse_iterator, typename mapped_type::super_const_reverse_iterator>&>(*this).equals(cursor);
600  }
601 
602 
603  /**
604  * Equality of super reverse iterator.
605  *
606  * \param cursor super reverse iterator
607  * \return true if equal; else false
608  */
609  bool equals(const super_reverse_iterator& cursor) const
610  {
611  return equals(super_const_reverse_iterator(cursor));
612  }
613 
614  private:
615  /**
616  * Constructor.
617  *
618  * \param __begin begin of data
619  * \param __end end of data
620  */
622  const_reverse_iterator __end) :
623  reverse_iterator_helper<const_reverse_iterator, typename mapped_type::super_const_reverse_iterator>(__begin, __end)
624  {}
625  };
626 
627 
628  /**
629  * Get super iterator to begin of data.
630  *
631  * \return super iterator
632  */
633  super_const_iterator super_begin() const
634  {
635  return super_const_iterator(this->begin(), this->end());
636  }
637 
638 
639  /**
640  * Get super iterator to reverse begin of data
641  *
642  * \return super reverse iterator
643  */
644  super_const_reverse_iterator super_rbegin() const
645  {
646  return super_const_reverse_iterator(this->rbegin(), this->rend());
647  }
648 
649 
650  /**
651  * Get super iterator to end of data.
652  *
653  * \return super iterator
654  */
655  super_const_iterator super_end() const
656  {
657  return super_const_iterator(this->end(), this->end());
658  }
659 
660 
661  /**
662  * Get super iterator to reverse end of data.
663  *
664  * \return super reverse iterator
665  */
666  super_const_reverse_iterator super_rend() const
667  {
668  return super_const_reverse_iterator(this->rend(), this->rend());
669  }
670 
671 
672  /**
673  * Get super iterator to begin of data.
674  *
675  * \return super iterator
676  */
677  super_iterator super_begin()
678  {
679  return super_iterator(this->begin(), this->end());
680  }
681 
682 
683  /**
684  * Get super iterator to reverse begin of data.
685  *
686  * \return super iterator
687  */
688  super_reverse_iterator super_rbegin()
689  {
690  return super_reverse_iterator(this->rbegin(), this->rend());
691  }
692 
693 
694  /**
695  * Get super iterator to end of data.
696  *
697  * \return super iterator
698  */
699  super_iterator super_end()
700  {
701  return super_iterator(this->end(), this->end());
702  }
703 
704 
705  /**
706  * Get super iterator to reverse end of data.
707  *
708  * \return super iterator
709  */
710  super_reverse_iterator super_rend()
711  {
712  return super_reverse_iterator(this->rend(), this->rend());
713  }
714 
715 
716  /**
717  * Get value.
718  *
719  * \param key multidimensional key
720  * \return value
721  */
723  {
724  return this->get(key.first).get(key.second);
725  }
726 
727 
728  /**
729  * Insert element.
730  *
731  * \param key multidimensional key
732  * \param value value
733  */
735  {
736  (*this)[key.first].insert(key.second, value);
737  }
738 
739 
740  /**
741  * Insert element.
742  *
743  * \param value multidimensional pair
744  */
746  {
747  (*this)[value.first].insert(value.second);
748  }
749 
750 
751  /**
752  * Insert element.
753  *
754  * \param value multidimensional pair
755  */
757  {
758  (*this)[value.first].insert(value.second);
759  }
760  };
761 
762 
763  /**
764  * Terminator class of recursive JMultiMap class.
765  */
766  template<class JAbscissa_t,
767  class JOrdinate_t,
768  template<class, class, class> class JHead_t,
769  class JDistance_t>
770  class JMultiMap<JAbscissa_t, JOrdinate_t, JMapList<JHead_t, JLANG::JNullType>, JDistance_t> :
771  public JHead_t<JAbscissa_t, JOrdinate_t, JDistance_t>,
772  public JMath< JMultiMap<JAbscissa_t, JOrdinate_t, JMapList<JHead_t, JLANG::JNullType>, JDistance_t> >
773  {
774  public:
775 
776  enum { NUMBER_OF_DIMENSIONS = 1 };
777 
778  typedef JHead_t<JAbscissa_t, JOrdinate_t, JDistance_t> map_type;
779 
780  typedef JAbscissa_t abscissa_type;
781  typedef JOrdinate_t ordinate_type;
782 
783  typedef typename map_type::key_type key_type;
784  typedef typename map_type::mapped_type mapped_type;
785  typedef typename map_type::value_type value_type;
786 
787  typedef typename map_type::const_iterator const_iterator;
788  typedef typename map_type::const_reverse_iterator const_reverse_iterator;
789  typedef typename map_type::iterator iterator;
790  typedef typename map_type::reverse_iterator reverse_iterator;
791 
792  using map_type::insert;
793  using map_type::configure;
794  using map_type::get;
795 
796 
797  /**
798  * Default constructor.
799  */
801  {}
802 
803 
804  /**
805  * Add map.
806  *
807  * \param map multimap
808  * \return this multimap
809  */
811  {
812  static_cast<map_type&>(*this).add(static_cast<const map_type&>(map));
813 
814  return *this;
815  }
816 
817 
818  /**
819  * Subtract map.
820  *
821  * \param map multimap
822  * \return this multimap
823  */
825  {
826  static_cast<map_type&>(*this).sub(static_cast<const map_type&>(map));
827 
828  return *this;
829  }
830 
831 
832  /**
833  * Scale contents.
834  *
835  * \param value multiplication factor
836  * \return this multimap
837  */
838  JMultiMap& mul(const double value)
839  {
840  static_cast<map_type&>(*this).mul(value);
841 
842  return *this;
843  }
844 
845  /**
846  * Scale contents.
847  *
848  * \param value division factor
849  * \return this multimap
850  */
851  JMultiMap& div(const double value)
852  {
853  static_cast<map_type&>(*this).div(value);
854 
855  return *this;
856  }
857 
858 
859  /**
860  * Termination of function application.
861  *
862  * \param function function
863  * \return function
864  */
865  template<class JFunction_t>
866  void for_each(const JFunction_t& function)
867  {
868  function(*this);
869  }
870 
871 
872  /**
873  * Configure multidimensional map.
874  *
875  * \param bounds multidimensional bounds
876  */
878  {
879  this->configure(JMultiKey<0, abscissa_type>(), bounds);
880  }
881 
882 
883  /**
884  * Configure multidimensional map.
885  *
886  * \param key multidimensional key
887  * \param bounds multidimensional bounds
888  */
889  template<unsigned int N, unsigned int M>
891  {
892  this->configure(bounds(key));
893  }
894 
895  private:
896 
897  /**
898  * Helper class for multidimensional iterator.
899  */
900  template<class iterator_type, class ordinate_type>
901  struct iterator_helper :
902  public JEquals < iterator_helper<iterator_type, ordinate_type> >,
903  public JForwardIterator< iterator_helper<iterator_type, ordinate_type> >
904  {
909 
910 
911  /**
912  * Auxiliary class for pair via smart pointer.
913  */
914  struct pointer_type :
915  private JPair<const key_type, value_type>
916  {
917  /**
918  * Constructor.
919  *
920  * \param key key
921  * \param value value
922  */
923  pointer_type(const key_type key, value_type value) :
924  JPair<const key_type, value_type>(key, value)
925  {}
926 
927 
928  /**
929  * Smart pointer operator.
930  *
931  * \return pointer to object
932  */
934  {
935  return this;
936  }
937  };
938 
939 
940  /**
941  * Default constructor.
942  */
944  {}
945 
946 
947  /**
948  * Constructor.
949  *
950  * \param __begin begin of data
951  * \param __end end of data
952  */
953  iterator_helper(iterator_type __begin,
954  iterator_type __end) :
955  range(__begin, __end),
956  i(__begin)
957  {}
958 
959 
960  /**
961  * Smart pointer operator.
962  *
963  * \return pointer to pair of iterators
964  */
965  pointer_type operator->()
966  {
967  return pointer_type(i->getX(), i->getY());
968  }
969 
970 
971  /**
972  * Dereference operator.
973  *
974  * \return multidimensional pair
975  */
977  {
978  return multipair_type(i->getX(), i->getY());
979  }
980 
981 
982  /**
983  * Equality of super iterator.
984  *
985  * \param cursor super iterator
986  * \return true if equal; else false
987  */
988  bool equals(const iterator_helper& cursor) const
989  {
990  return i == cursor.i;
991  }
992 
993 
994  /**
995  * Increment super iterator.
996  *
997  * \return true if valid; else false
998  */
999  virtual bool increment() override
1000  {
1001  return ++i != range.second;
1002  }
1003 
1004 
1005  /**
1006  * Get multidimensional key.
1007  *
1008  * \return key
1009  */
1011  {
1012  return multikey_type(i->getX());
1013  }
1014 
1015 
1016  /**
1017  * Get value.
1018  *
1019  * \return value
1020  */
1022  {
1023  return i->getY();
1024  }
1025 
1026 
1028  iterator_type i;
1029  };
1030 
1031  public:
1032 
1033  class super_const_iterator; // forward declaration
1034 
1035 
1036  /**
1037  * Terminator class of multidimensional iterator.
1038  */
1039  struct super_iterator :
1040  public iterator_helper<iterator, ordinate_type&>
1041  {
1042 
1043  friend class JMultiMap;
1044  friend class super_const_iterator;
1045 
1046  /**
1047  * Default constructor.
1048  */
1050  {}
1051 
1052  private:
1053  /**
1054  * Constructor.
1055  *
1056  * \param __begin begin of data
1057  * \param __end end of data
1058  */
1060  iterator __end) :
1061  iterator_helper<iterator, ordinate_type&>(__begin, __end)
1062  {}
1063  };
1064 
1065 
1066  /**
1067  * Terminator class of multidimensional const_iterator.
1068  */
1069  struct super_const_iterator :
1070  public iterator_helper<const_iterator, const ordinate_type&>,
1071  public JEquals<super_const_iterator, super_iterator>
1072  {
1073 
1074  friend class JMultiMap;
1075 
1076  /**
1077  * Default constructor.
1078  */
1080  {}
1081 
1082 
1083  /**
1084  * Copy constructor.
1085  *
1086  * \param cursor super iterator
1087  */
1088  super_const_iterator(super_iterator cursor)
1089  {
1090  this->range = cursor.range;
1091  this->i = cursor.i;
1092  }
1093 
1094 
1095  /**
1096  * Equality of super iterator.
1097  *
1098  * \param cursor super iterator
1099  * \return true if equal; else false
1100  */
1101  bool equals(const super_const_iterator& cursor) const
1102  {
1103  return this->i == cursor.i;
1104  }
1105 
1106 
1107  /**
1108  * Equality of super iterator.
1109  *
1110  * \param cursor super iterator
1111  * \return true if equal; else false
1112  */
1113  bool equals(const super_iterator& cursor) const
1114  {
1115  return this->i == cursor.i;
1116  }
1117 
1118  private:
1119  /**
1120  * Constructor.
1121  *
1122  * \param __begin begin of data
1123  * \param __end end of data
1124  */
1126  const_iterator __end) :
1127  iterator_helper<const_iterator, const ordinate_type&>(__begin, __end)
1128  {}
1129  };
1130 
1131 
1132  class super_const_reverse_iterator; // forward declaration
1133 
1134 
1135  /**
1136  * Terminator class of multidimensional reverse iterator.
1137  */
1138  struct super_reverse_iterator :
1139  public iterator_helper<reverse_iterator, ordinate_type&>
1140  {
1141 
1142  friend class JMultiMap;
1143  friend class super_const_reverse_iterator;
1144 
1145  /**
1146  * Default constructor.
1147  */
1149  {}
1150 
1151  private:
1152  /**
1153  * Constructor.
1154  *
1155  * \param __begin begin of data
1156  * \param __end end of data
1157  */
1159  reverse_iterator __end) :
1160  iterator_helper<reverse_iterator, ordinate_type&>(__begin, __end)
1161  {}
1162  };
1163 
1164 
1165  /**
1166  * Terminator class of multidimensional const_iterator.
1167  */
1168  struct super_const_reverse_iterator :
1169  public iterator_helper<const_reverse_iterator, const ordinate_type&>,
1170  public JEquals<super_const_reverse_iterator, super_reverse_iterator>
1171  {
1172 
1173  friend class JMultiMap;
1174 
1175  /**
1176  * Default constructor.
1177  */
1179  {}
1180 
1181 
1182  /**
1183  * Copy constructor.
1184  *
1185  * \param cursor super reverse iterator
1186  */
1187  super_const_reverse_iterator(super_reverse_iterator cursor)
1188  {
1189  this->range = cursor.range;
1190  this->i = cursor.i;
1191  }
1192 
1193 
1194  /**
1195  * Equality of super reverse iterator.
1196  *
1197  * \param cursor super reverse iterator
1198  * \return true if equal; else false
1199  */
1200  bool equals(const super_const_reverse_iterator& cursor) const
1201  {
1202  return this->i == cursor.i;
1203  }
1204 
1205 
1206  /**
1207  * Equality of super reverse iterator.
1208  *
1209  * \param cursor super reverse iterator
1210  * \return true if equal; else false
1211  */
1212  bool equals(const super_reverse_iterator& cursor) const
1213  {
1214  return this->i == cursor.i;
1215  }
1216 
1217  private:
1218  /**
1219  * Constructor.
1220  *
1221  * \param __begin begin of data
1222  * \param __end end of data
1223  */
1225  const_reverse_iterator __end) :
1226  iterator_helper<const_reverse_iterator, const ordinate_type&>(__begin, __end)
1227  {}
1228  };
1229 
1230 
1231  /**
1232  * Get super iterator to begin of data.
1233  *
1234  * \return super iterator
1235  */
1236  super_const_iterator super_begin() const
1237  {
1238  return super_const_iterator(this->begin(), this->end());
1239  }
1240 
1241 
1242  /**
1243  * Get super iterator to reverse begin of data.
1244  *
1245  * \return super reverse iterator
1246  */
1247  super_const_reverse_iterator super_rbegin() const
1248  {
1249  return super_const_reverse_iterator(this->rbegin(), this->rend());
1250  }
1251 
1252 
1253  /**
1254  * Get super iterator to end of data.
1255  *
1256  * \return super iterator
1257  */
1258  super_const_iterator super_end() const
1259  {
1260  return super_const_iterator(this->end(), this->end());
1261  }
1262 
1263 
1264  /**
1265  * Get super iterator to reverse end of data.
1266  *
1267  * \return super reverse iterator
1268  */
1269  super_const_reverse_iterator super_rend() const
1270  {
1271  return super_const_reverse_iterator(this->rend(), this->rend());
1272  }
1273 
1274 
1275  /**
1276  * Get super iterator to begin of data.
1277  *
1278  * \return super iterator
1279  */
1280  super_iterator super_begin()
1281  {
1282  return super_iterator(this->begin(), this->end());
1283  }
1284 
1285 
1286  /**
1287  * Get super iterator to reverse begin of data.
1288  *
1289  * \return super reverse iterator
1290  */
1291  super_reverse_iterator super_rbegin()
1292  {
1293  return super_reverse_iterator(this->rbegin(), this->rend());
1294  }
1295 
1296 
1297  /**
1298  * Get super iterator to end of data.
1299  *
1300  * \return super iterator
1301  */
1302  super_iterator super_end()
1303  {
1304  return super_iterator(this->end(), this->end());
1305  }
1306 
1307 
1308  /**
1309  * Get super iterator to reverse end of data.
1310  *
1311  * \return super reverse iterator
1312  */
1313  super_reverse_iterator super_rend()
1314  {
1315  return super_reverse_iterator(this->rend(), this->rend());
1316  }
1317 
1318 
1319  /**
1320  * Get value.
1321  *
1322  * \param key multidimensional key
1323  * \return value
1324  */
1326  {
1327  return get(key.first);
1328  }
1329 
1330 
1331  /**
1332  * Insert element.
1333  *
1334  * \param key multidimensional key
1335  * \param value value
1336  */
1338  {
1339  insert(value_type(key.first, value));
1340  }
1341 
1342 
1343  /**
1344  * Insert element.
1345  *
1346  * \param value multidimensional pair
1347  */
1349  {
1350  insert(value_type(value.first, value.second));
1351  }
1352 
1353 
1354  /**
1355  * Insert element.
1356  *
1357  * \param value multidimensional pair
1358  */
1360  {
1361  insert(value_type(value.first, value.second));
1362  }
1363  };
1364 }
1365 
1366 #endif
super_const_iterator super_begin() const
Get super iterator to begin of data.
Definition: JMultiMap.hh:633
super_const_reverse_iterator super_rend() const
Get super iterator to reverse end of data.
Definition: JMultiMap.hh:1269
Template interface for method bool increment().
void for_each(const JFunction_t &function)
Termination of function application.
Definition: JMultiMap.hh:866
super_reverse_iterator super_rend()
Get super iterator to reverse end of data.
Definition: JMultiMap.hh:1313
super_const_reverse_iterator super_rend() const
Get super iterator to reverse end of data.
Definition: JMultiMap.hh:666
mapped_type second
Definition: JMultiPair.hh:125
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:109
void insert(const JMultiPair< NUMBER_OF_DIMENSIONS, const abscissa_type, ordinate_type & > &value)
Insert element.
Definition: JMultiMap.hh:1359
bool equals(const super_const_reverse_iterator &cursor) const
Equality of super reverse iterator.
Definition: JMultiMap.hh:597
bool equals(const super_const_iterator &cursor) const
Equality of super iterator.
Definition: JMultiMap.hh:497
Template class for distance evaluation.
Definition: JDistance.hh:24
void insert(const JMultiPair< NUMBER_OF_DIMENSIONS, const abscissa_type, ordinate_type & > &value)
Insert element.
Definition: JMultiMap.hh:756
void configure(const JAbstractMultiMap< NUMBER_OF_DIMENSIONS, abscissa_type > &bounds)
Configure multidimensional map.
Definition: JMultiMap.hh:176
T get(const JHead &header)
Get object from header.
Length of map list.
Definition: JMapList.hh:45
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
Abstract interface for abscissa values of a multidimensional map.
bool equals(const super_const_reverse_iterator &cursor) const
Equality of super reverse iterator.
Definition: JMultiMap.hh:1200
void insert(const JMultiPair< NUMBER_OF_DIMENSIONS, const abscissa_type, const ordinate_type & > &value)
Insert element.
Definition: JMultiMap.hh:745
Multidimensional key.
Definition: JMultiKey.hh:34
super_reverse_iterator super_rbegin()
Get super iterator to reverse begin of data.
Definition: JMultiMap.hh:688
Template specialisation for a pair of values.
Definition: JPair.hh:28
super_const_reverse_iterator super_rbegin() const
Get super iterator to reverse begin of data.
Definition: JMultiMap.hh:1247
Map list.
Definition: JMapList.hh:24
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
void configure(const JMultiKey< M, abscissa_type > &key, const JAbstractMultiMap< N, abscissa_type > &bounds)
Configure multidimensional map.
Definition: JMultiMap.hh:189
Auxiliary class for no type definition.
Definition: JNullType.hh:19
super_const_iterator super_end() const
Get super iterator to end of data.
Definition: JMultiMap.hh:1258
super_reverse_iterator super_rend()
Get super iterator to reverse end of data.
Definition: JMultiMap.hh:710
void configure(const JMultiKey< M, abscissa_type > &key, const JAbstractMultiMap< N, abscissa_type > &bounds)
Configure multidimensional map.
Definition: JMultiMap.hh:890
void insert(const JMultiKey< NUMBER_OF_DIMENSIONS, const abscissa_type > &key, const ordinate_type &value)
Insert element.
Definition: JMultiMap.hh:1337
super_const_iterator super_end() const
Get super iterator to end of data.
Definition: JMultiMap.hh:655
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
bool equals(const super_reverse_iterator &cursor) const
Equality of super reverse iterator.
Definition: JMultiMap.hh:609
void insert(const JMultiKey< NUMBER_OF_DIMENSIONS, const abscissa_type > &key, const ordinate_type &value)
Insert element.
Definition: JMultiMap.hh:734
super_reverse_iterator super_rbegin()
Get super iterator to reverse begin of data.
Definition: JMultiMap.hh:1291
bool equals(const iterator_base &cursor) const
Equality of super iterator.
Definition: JMultiMap.hh:270
bool equals(const super_reverse_iterator &cursor) const
Equality of super reverse iterator.
Definition: JMultiMap.hh:1212
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
super_const_reverse_iterator(const_reverse_iterator __begin, const_reverse_iterator __end)
Constructor.
Definition: JMultiMap.hh:621
JMultiPair< NUMBER_OF_DIMENSIONS, const abscissa_type, value_type > multipair_type
Definition: JMultiMap.hh:210
JHead_t< JAbscissa_t, JMultiMap< JAbscissa_t, JOrdinate_t, JTail_t, JDistance_t >, JDistance_t > map_type
Definition: JMultiMap.hh:73
Base class for data structures with artithmetic capabilities.
const JPair< const key_type, second_iterator & > * operator->() const
Smart pointer operator.
Definition: JMultiMap.hh:235
Multidimensional pair.
Definition: JMultiPair.hh:30
void insert(const JMultiPair< NUMBER_OF_DIMENSIONS, const abscissa_type, const ordinate_type & > &value)
Insert element.
Definition: JMultiMap.hh:1348
void for_each(const JFunction_t &function)
Function application to each element of this multimap.
Definition: JMultiMap.hh:161
bool equals(const JFirst_t &first, const JSecond_t &second, const double precision=std::numeric_limits< double >::min())
Check equality.
Definition: JMathToolkit.hh:86
void configure(const JAbstractMultiMap< NUMBER_OF_DIMENSIONS, abscissa_type > &bounds)
Configure multidimensional map.
Definition: JMultiMap.hh:877
const char * map
Definition: elog.cc:87
super_const_reverse_iterator super_rbegin() const
Get super iterator to reverse begin of data.
Definition: JMultiMap.hh:644
Multidimensional map.
Definition: JMultiMap.hh:52
super_const_iterator super_begin() const
Get super iterator to begin of data.
Definition: JMultiMap.hh:1236