ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArBadChannelTool
src
combined_ordered_iterator.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef combined_ordered_iterator_H
6
#define combined_ordered_iterator_H
7
14
15
namespace
LArBadChanImpl
{
16
17
template
<
class
Iter,
class
CMP>
18
class
combined_ordered_iterator
{
19
public
:
20
21
typedef
typename
Iter::value_type
value_type
;
22
23
combined_ordered_iterator
(
const
Iter& b1,
const
Iter& e1,
24
const
Iter& b2,
const
Iter& e2,
const
CMP& cmp) :
25
m_b1
(b1),
m_e1
(e1),
m_b2
(b2),
m_e2
(e2),
m_cmp
(cmp)
26
{
27
m_first
=
m_cmp
( *
m_b1
, *
m_b2
);
28
}
29
30
combined_ordered_iterator
() :
m_b1
(Iter()),
m_e1
(Iter()),
31
m_b2
(Iter()),
m_e2
(Iter()),
m_cmp
(CMP()),
32
m_first
(false){}
33
34
combined_ordered_iterator
&
operator++
() {
35
advance
();
36
if
(
at_the_end
())
switch_to_other
();
37
else
if
( !
other_at_the_end
()) {
38
if
(
m_cmp
(
other
(),
current
()))
switch_to_other
();
// we must switch to the other container
39
}
40
return
*
this
;
41
}
42
43
combined_ordered_iterator
operator++
(
int
) {
44
combined_ordered_iterator
tmp(*
this
);
45
operator++
();
46
return
tmp;
47
}
48
49
const
value_type
&
operator*
() {
50
return
current
();
51
}
52
53
operator
bool()
const
{
return
m_b1
!=
m_e1
||
m_b2
!=
m_e2
;}
54
55
bool
operator!=
(
const
combined_ordered_iterator
&
other
)
const
{
56
if
(
at_the_end
())
return
!
other
.at_the_end();
57
else
if
(
other
.at_the_end())
return
true
;
58
else
return
current_iter
() !=
other
.current_iter();
59
}
60
61
bool
operator==
(
const
combined_ordered_iterator
&
other
)
const
{
62
return
!
operator!=
(
other
);
63
}
64
65
private
:
66
67
Iter
m_b1
;
68
Iter
m_e1
;
69
Iter
m_b2
;
70
Iter
m_e2
;
71
CMP
m_cmp
;
72
bool
m_first
;
73
74
const
value_type
&
other
()
const
{
return
m_first
? *
m_b2
: *
m_b1
;}
75
76
const
value_type
&
current
()
const
{
return
m_first
? *
m_b1
: *
m_b2
;}
77
78
const
Iter&
current_iter
()
const
{
return
m_first
?
m_b1
:
m_b2
;}
79
80
const
value_type
&
next_in_same
()
const
{
81
Iter tmp = (
m_first
?
m_b1
:
m_b2
);
82
return
*(++tmp);
83
}
84
85
void
advance
() {
86
if
(
m_first
) {
87
if
(
m_b1
!=
m_e1
) ++
m_b1
;
88
}
89
else
{
90
if
(
m_b2
!=
m_e2
) ++
m_b2
;
91
}
92
}
93
94
bool
at_the_end
()
const
{
95
return
m_first
? (
m_b1
==
m_e1
) : (
m_b2
==
m_e2
);
96
}
97
98
bool
other_at_the_end
()
const
{
99
return
m_first
? (
m_b2
==
m_e2
) : (
m_b1
==
m_e1
);
100
}
101
102
void
switch_to_other
() {
m_first
= !
m_first
;}
103
104
};
105
106
}
107
108
#endif
LArBadChanImpl::combined_ordered_iterator::switch_to_other
void switch_to_other()
Definition
combined_ordered_iterator.h:102
LArBadChanImpl::combined_ordered_iterator::at_the_end
bool at_the_end() const
Definition
combined_ordered_iterator.h:94
LArBadChanImpl::combined_ordered_iterator::operator++
combined_ordered_iterator & operator++()
Definition
combined_ordered_iterator.h:34
LArBadChanImpl::combined_ordered_iterator::other
const value_type & other() const
Definition
combined_ordered_iterator.h:74
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_cmp
CMP m_cmp
Definition
combined_ordered_iterator.h:71
LArBadChanImpl::combined_ordered_iterator::operator*
const value_type & operator*()
Definition
combined_ordered_iterator.h:49
LArBadChanImpl::combined_ordered_iterator::current
const value_type & current() const
Definition
combined_ordered_iterator.h:76
LArBadChanImpl::combined_ordered_iterator::next_in_same
const value_type & next_in_same() const
Definition
combined_ordered_iterator.h:80
LArBadChanImpl::combined_ordered_iterator::combined_ordered_iterator
combined_ordered_iterator(const Iter &b1, const Iter &e1, const Iter &b2, const Iter &e2, const CMP &cmp)
Definition
combined_ordered_iterator.h:23
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_e2
typename Cont::const_iterator m_e2
Definition
combined_ordered_iterator.h:70
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_b2
typename Cont::const_iterator m_b2
Definition
combined_ordered_iterator.h:69
LArBadChanImpl::combined_ordered_iterator::current_iter
const Iter & current_iter() const
Definition
combined_ordered_iterator.h:78
LArBadChanImpl::combined_ordered_iterator::operator==
bool operator==(const combined_ordered_iterator &other) const
Definition
combined_ordered_iterator.h:61
LArBadChanImpl::combined_ordered_iterator::operator++
combined_ordered_iterator operator++(int)
Definition
combined_ordered_iterator.h:43
LArBadChanImpl::combined_ordered_iterator::other_at_the_end
bool other_at_the_end() const
Definition
combined_ordered_iterator.h:98
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_e1
typename Cont::const_iterator m_e1
Definition
combined_ordered_iterator.h:68
LArBadChanImpl::combined_ordered_iterator::advance
void advance()
Definition
combined_ordered_iterator.h:85
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_first
bool m_first
Definition
combined_ordered_iterator.h:72
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::m_b1
typename Cont::const_iterator m_b1
Definition
combined_ordered_iterator.h:67
LArBadChanImpl::combined_ordered_iterator::operator!=
bool operator!=(const combined_ordered_iterator &other) const
Definition
combined_ordered_iterator.h:55
LArBadChanImpl::combined_ordered_iterator::combined_ordered_iterator
combined_ordered_iterator()
Definition
combined_ordered_iterator.h:30
LArBadChanImpl::combined_ordered_iterator< typename Cont::const_iterator, CMP >::value_type
typename Cont::const_iterator::value_type value_type
Definition
combined_ordered_iterator.h:21
LArBadChanImpl
A helper class that provides iterators over elements in two separate ordered containers as if the ele...
Definition
combined_ordered_container.h:16
Generated on
for ATLAS Offline Software by
1.17.0