ATLAS Offline Software
Loading...
Searching...
No Matches
TestClassSTLContainers Class Reference

#include <TestClassSTLContainers.h>

Collaboration diagram for TestClassSTLContainers:

Public Member Functions

 TestClassSTLContainers ()=default
void setNonZero ()
bool operator== (const TestClassSTLContainers &rhs) const
bool operator!= (const TestClassSTLContainers &rhs) const
std::ostream & streamOut (std::ostream &os) const

Public Attributes

std::vector< int > m_vector_of_int
std::map< std::string, long > m_map_of_string_to_long
std::set< unsigned short > m_set_of_ushort

Detailed Description

Definition at line 14 of file TestClassSTLContainers.h.

Constructor & Destructor Documentation

◆ TestClassSTLContainers()

TestClassSTLContainers::TestClassSTLContainers ( )
default

Member Function Documentation

◆ operator!=()

bool TestClassSTLContainers::operator!= ( const TestClassSTLContainers & rhs) const
inline

Definition at line 105 of file TestClassSTLContainers.h.

106{
107 return ( ( (*this) == rhs ) ? false : true );
108}

◆ operator==()

bool TestClassSTLContainers::operator== ( const TestClassSTLContainers & rhs) const
inline

Definition at line 68 of file TestClassSTLContainers.h.

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}
std::vector< int > m_vector_of_int
std::map< std::string, long > m_map_of_string_to_long
std::set< unsigned short > m_set_of_ushort

◆ setNonZero()

void TestClassSTLContainers::setNonZero ( )
inline

Definition at line 31 of file TestClassSTLContainers.h.

32{
33 m_vector_of_int.clear();
34 m_vector_of_int.push_back( 1 );
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}

◆ streamOut()

std::ostream & TestClassSTLContainers::streamOut ( std::ostream & os) const
inline

Definition at line 45 of file TestClassSTLContainers.h.

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}

Member Data Documentation

◆ m_map_of_string_to_long

std::map< std::string, long > TestClassSTLContainers::m_map_of_string_to_long

Definition at line 25 of file TestClassSTLContainers.h.

◆ m_set_of_ushort

std::set< unsigned short > TestClassSTLContainers::m_set_of_ushort

Definition at line 26 of file TestClassSTLContainers.h.

◆ m_vector_of_int

std::vector< int > TestClassSTLContainers::m_vector_of_int

Definition at line 24 of file TestClassSTLContainers.h.


The documentation for this class was generated from the following file: