1#ifndef __JTOOLS__JMULTIMAP__
2#define __JTOOLS__JMULTIMAP__
48 template<
class JAbscissa_t,
58 template<
class JAbscissa_t,
60 template<
class,
class,
class>
class JHead_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> >
71 typedef JHead_t<JAbscissa_t,
87 using map_type::insert;
88 using map_type::configure;
135 static_cast<map_type&
>(*this).mul(value);
148 static_cast<map_type&
>(*this).div(value);
159 template<
class JFunction_t>
164 for (
iterator i = this->begin(); i != this->end(); ++i) {
165 i->getY().for_each(function);
187 template<
unsigned int N,
unsigned int M>
192 for (
iterator i = this->begin(); i != this->end(); ++i) {
202 template<
class first_iterator,
class second_iterator>
203 struct iterator_base :
204 public JEquals< iterator_base<first_iterator, second_iterator> >
208 typedef JMultiKey <NUMBER_OF_DIMENSIONS, const abscissa_type>
multikey_type;
215 struct pointer_type :
216 private JPair<const key_type, second_iterator>
248 return pointer_type(i->getX(), second);
269 bool equals(
const iterator_base& cursor)
const
271 return i == cursor.i && (i == range.second || second.equals(cursor.second));
293 return this->second.getValue();
307 template<
class first_iterator,
class second_iterator>
308 struct iterator_helper :
309 public iterator_base<first_iterator, second_iterator>,
326 first_iterator __end)
328 this->range = std::make_pair(__begin, __end);
330 for (this->i = this->range.first; this->i != this->range.second; ++(this->i)) {
332 this->second = this->i->getY().super_begin();
334 if (this->second != this->i->getY().super_end()) {
348 if (!this->second.increment()) {
350 while (++(this->i) != this->range.second) {
352 this->second = this->i->getY().super_begin();
354 if (this->second != this->i->getY().super_end()) {
360 return this->i != this->range.second;
368 template<
class first_iterator,
class second_iterator>
369 struct reverse_iterator_helper :
370 public iterator_base<first_iterator, second_iterator>,
371 public JForwardIterator< reverse_iterator_helper<first_iterator, second_iterator> >
387 first_iterator __end)
389 this->range = std::make_pair(__begin, __end);
391 for (this->i = this->range.first; this->i != this->range.second; ++(this->i)) {
393 this->second = this->i->getY().super_rbegin();
395 if (this->second != this->i->getY().super_rend()) {
409 if (!this->second.increment()) {
411 while (++(this->i) != this->range.second) {
413 this->second = this->i->getY().super_rbegin();
415 if (this->second != this->i->getY().super_rend()) {
421 return this->i != this->range.second;
427 class super_const_iterator;
433 class super_iterator :
434 public iterator_helper<iterator, typename mapped_type::super_iterator>
438 friend class super_const_iterator;
463 class super_const_iterator :
464 public iterator_helper<const_iterator, typename mapped_type::super_const_iterator>,
465 public JEquals<super_const_iterator, super_iterator>
484 this->range = cursor.range;
486 this->second = cursor.second;
496 bool equals(
const super_const_iterator& cursor)
const
498 return static_cast<const iterator_base<const_iterator, typename mapped_type::super_const_iterator>&
>(*this).equals(cursor);
508 bool equals(
const super_iterator& cursor)
const
510 return equals(super_const_iterator(cursor));
527 class super_const_reverse_iterator;
533 class super_reverse_iterator :
534 public reverse_iterator_helper<reverse_iterator, typename mapped_type::super_reverse_iterator>
538 friend class super_const_reverse_iterator;
563 class super_const_reverse_iterator :
564 public reverse_iterator_helper<const_reverse_iterator, typename mapped_type::super_const_reverse_iterator>,
565 public JEquals<super_const_reverse_iterator, super_reverse_iterator>
584 this->range = cursor.range;
586 this->second = cursor.second;
596 bool equals(
const super_const_reverse_iterator& cursor)
const
598 return static_cast<const iterator_base<const_reverse_iterator, typename mapped_type::super_const_reverse_iterator>&
>(*this).equals(cursor);
608 bool equals(
const super_reverse_iterator& cursor)
const
610 return equals(super_const_reverse_iterator(cursor));
634 return super_const_iterator(this->begin(), this->end());
645 return super_const_reverse_iterator(this->rbegin(), this->rend());
656 return super_const_iterator(this->end(), this->end());
667 return super_const_reverse_iterator(this->rend(), this->rend());
678 return super_iterator(this->begin(), this->end());
689 return super_reverse_iterator(this->rbegin(), this->rend());
700 return super_iterator(this->end(), this->end());
711 return super_reverse_iterator(this->rend(), this->rend());
723 return this->get(key.first).get(key.second);
735 return this->get(key.first).get(key.second);
747 (*this)[key.first].insert(key.second, value);
766 template<
class JAbscissa_t,
768 template<
class,
class,
class>
class JHead_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> >
776 enum { NUMBER_OF_DIMENSIONS = 1 };
778 typedef JHead_t<JAbscissa_t, JOrdinate_t, JDistance_t>
map_type;
792 using map_type::insert;
793 using map_type::configure;
840 static_cast<map_type&
>(*this).mul(value);
853 static_cast<map_type&
>(*this).div(value);
864 template<
class JFunction_t>
888 template<
unsigned int N,
unsigned int M>
899 template<
class iterator_type,
class ordinate_type>
900 struct iterator_helper :
901 public JEquals < iterator_helper<iterator_type, ordinate_type> >,
906 typedef JMultiKey <NUMBER_OF_DIMENSIONS, const abscissa_type>
multikey_type;
913 struct pointer_type :
914 private JPair<const key_type, value_type>
953 iterator_type __end) :
954 range(__begin, __end),
966 return pointer_type(i->getX(), i->getY());
987 bool equals(
const iterator_helper& cursor)
const
989 return i == cursor.i;
1000 return ++i != range.second;
1032 class super_const_iterator;
1038 class super_iterator :
1039 public iterator_helper<iterator, ordinate_type&>
1043 friend class super_const_iterator;
1068 class super_const_iterator :
1069 public iterator_helper<const_iterator, const ordinate_type&>,
1070 public JEquals<super_const_iterator, super_iterator>
1089 this->range = cursor.range;
1100 bool equals(
const super_const_iterator& cursor)
const
1102 return this->i == cursor.i;
1112 bool equals(
const super_iterator& cursor)
const
1114 return this->i == cursor.i;
1131 class super_const_reverse_iterator;
1137 class super_reverse_iterator :
1138 public iterator_helper<reverse_iterator, ordinate_type&>
1142 friend class super_const_reverse_iterator;
1167 class super_const_reverse_iterator :
1168 public iterator_helper<const_reverse_iterator, const ordinate_type&>,
1169 public JEquals<super_const_reverse_iterator, super_reverse_iterator>
1188 this->range = cursor.range;
1199 bool equals(
const super_const_reverse_iterator& cursor)
const
1201 return this->i == cursor.i;
1211 bool equals(
const super_reverse_iterator& cursor)
const
1213 return this->i == cursor.i;
1237 return super_const_iterator(this->begin(), this->end());
1248 return super_const_reverse_iterator(this->rbegin(), this->rend());
1259 return super_const_iterator(this->end(), this->end());
1270 return super_const_reverse_iterator(this->rend(), this->rend());
1281 return super_iterator(this->begin(), this->end());
1292 return super_reverse_iterator(this->rbegin(), this->rend());
1303 return super_iterator(this->end(), this->end());
1314 return super_reverse_iterator(this->rend(), this->rend());
1326 return get(key.first);
1338 return get(key.first);
Base class for data structures with artithmetic capabilities.
Template interface for method bool increment().
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template definition of auxiliary base class for comparison of data structures.
Auxiliary class for no type definition.
Auxiliary base class for aritmetic operations of derived class types.