ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
APR
APRTests
TestDictionary
TestClassSTLContainers.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef TESTCLASSSTLCONTAINERS_H
6
#define TESTCLASSSTLCONTAINERS_H
7
8
#include <string>
9
#include <vector>
10
#include <map>
11
#include <set>
12
#include <ostream>
13
14
class
TestClassSTLContainers
{
15
16
public
:
17
TestClassSTLContainers
() =
default
;
18
19
void
setNonZero
();
20
bool
operator==
(
const
TestClassSTLContainers
& rhs )
const
;
21
bool
operator!=
(
const
TestClassSTLContainers
& rhs )
const
;
22
std::ostream&
streamOut
( std::ostream& os )
const
;
23
24
std::vector< int >
m_vector_of_int
;
25
std::map< std::string, long >
m_map_of_string_to_long
;
26
std::set< unsigned short >
m_set_of_ushort
;
27
};
28
29
30
inline
void
31
TestClassSTLContainers::setNonZero
()
32
{
33
m_vector_of_int
.clear();
34
m_vector_of_int
.push_back( 1 );
35
m_map_of_string_to_long
.clear();
36
m_map_of_string_to_long
.insert( std::make_pair( std::string(
"key1"
), 4L ) );
37
m_map_of_string_to_long
.insert( std::make_pair( std::string(
"key2"
), 5L ) );
38
m_set_of_ushort
.clear();
39
m_set_of_ushort
.insert( 6 );
40
m_set_of_ushort
.insert( 7 );
41
m_set_of_ushort
.insert( 8 );
42
}
43
44
inline
std::ostream&
45
TestClassSTLContainers::streamOut
( std::ostream& os )
const
46
{
47
os <<
"m_vector_of_int( "
<<
m_vector_of_int
.size() <<
" ) :"
;
48
for
( std::vector< int >::const_iterator i =
m_vector_of_int
.begin();
49
i !=
m_vector_of_int
.end(); ++i ) {
50
os <<
" "
<< *i;
51
}
52
os << std::endl;
53
os <<
"m_map_of_string_to_long( "
<<
m_map_of_string_to_long
.size() <<
" ) :"
;
54
for
( std::map< std::string, long >::const_iterator i =
m_map_of_string_to_long
.begin();
55
i !=
m_map_of_string_to_long
.end(); ++i ) {
56
os <<
" ("
<< i->first <<
","
<< i->second <<
")"
;
57
}
58
os << std::endl;
59
os <<
"m_set_of_ushort( "
<<
m_set_of_ushort
.size() <<
" ) :"
;
60
for
( std::set< unsigned short >::const_iterator i =
m_set_of_ushort
.begin();
61
i !=
m_set_of_ushort
.end(); ++i ) {
62
os <<
" "
<< *i;
63
}
64
return
os;
65
}
66
67
inline
bool
68
TestClassSTLContainers::operator==
(
const
TestClassSTLContainers
& rhs )
const
69
{
70
// Check first the sizes of the containers
71
if
(
m_vector_of_int
.size() != rhs.
m_vector_of_int
.size() )
return
false
;
72
if
(
m_map_of_string_to_long
.size() != rhs.
m_map_of_string_to_long
.size() )
return
false
;
73
if
(
m_set_of_ushort
.size() != rhs.
m_set_of_ushort
.size() )
return
false
;
74
75
// Check element by element.
76
std::vector< int >::const_iterator this_i_vector_of_int =
m_vector_of_int
.begin();
77
std::vector< int >::const_iterator rhs_i_vector_of_int = rhs.
m_vector_of_int
.begin();
78
while
( this_i_vector_of_int !=
m_vector_of_int
.end() ) {
79
if
( *this_i_vector_of_int != *rhs_i_vector_of_int )
return
false
;
80
++this_i_vector_of_int;
81
++rhs_i_vector_of_int;
82
}
83
84
std::map< std::string, long >::const_iterator this_i_map_of_string_to_long =
m_map_of_string_to_long
.begin();
85
std::map< std::string, long >::const_iterator rhs_i_map_of_string_to_long = rhs.
m_map_of_string_to_long
.begin();
86
while
( this_i_map_of_string_to_long !=
m_map_of_string_to_long
.end() ) {
87
if
( this_i_map_of_string_to_long->first != rhs_i_map_of_string_to_long->first ||
88
this_i_map_of_string_to_long->second != rhs_i_map_of_string_to_long->second )
return
false
;
89
++this_i_map_of_string_to_long;
90
++rhs_i_map_of_string_to_long;
91
}
92
93
std::set< unsigned short >::const_iterator this_i_set_of_ushort =
m_set_of_ushort
.begin();
94
std::set< unsigned short >::const_iterator rhs_i_set_of_ushort = rhs.
m_set_of_ushort
.begin();
95
while
( this_i_set_of_ushort !=
m_set_of_ushort
.end() ) {
96
if
( *this_i_set_of_ushort != *rhs_i_set_of_ushort )
return
false
;
97
++this_i_set_of_ushort;
98
++rhs_i_set_of_ushort;
99
}
100
101
return
true
;
102
}
103
104
inline
bool
105
TestClassSTLContainers::operator!=
(
const
TestClassSTLContainers
& rhs )
const
106
{
107
return
( ( (*
this
) == rhs ) ?
false
:
true
);
108
}
109
110
111
#endif
TestClassSTLContainers::m_vector_of_int
std::vector< int > m_vector_of_int
Definition
TestClassSTLContainers.h:24
TestClassSTLContainers::operator!=
bool operator!=(const TestClassSTLContainers &rhs) const
Definition
TestClassSTLContainers.h:105
TestClassSTLContainers::m_map_of_string_to_long
std::map< std::string, long > m_map_of_string_to_long
Definition
TestClassSTLContainers.h:25
TestClassSTLContainers::m_set_of_ushort
std::set< unsigned short > m_set_of_ushort
Definition
TestClassSTLContainers.h:26
TestClassSTLContainers::operator==
bool operator==(const TestClassSTLContainers &rhs) const
Definition
TestClassSTLContainers.h:68
TestClassSTLContainers::TestClassSTLContainers
TestClassSTLContainers()=default
TestClassSTLContainers::setNonZero
void setNonZero()
Definition
TestClassSTLContainers.h:31
TestClassSTLContainers::streamOut
std::ostream & streamOut(std::ostream &os) const
Definition
TestClassSTLContainers.h:45
Generated on
for ATLAS Offline Software by
1.17.0