ATLAS Offline Software
Loading...
Searching...
No Matches
TestClassSTLContainersExt.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 TESTCLASSSTLCONTAINERSEXT_H
6#define TESTCLASSSTLCONTAINERSEXT_H
7
8#include <string>
9#include <vector>
10#include <list>
11#include <deque>
12#include <ostream>
13
15
16public:
18
19 void setNonZero();
20 bool operator==( const TestClassSTLContainersExt& rhs ) const;
21 bool operator!=( const TestClassSTLContainersExt& rhs ) const;
22 std::ostream& streamOut( std::ostream& os ) const;
23
24 std::list< double > m_list_of_double;
25 std::deque< float > m_deque_of_float;
26};
27
28
29inline void
31{
32 m_list_of_double.clear();
33 m_list_of_double.push_back( 2 );
34 m_list_of_double.push_back( 3 );
35 m_deque_of_float.clear();
36 m_deque_of_float.push_back( 9 );
37 m_deque_of_float.push_front( 10 );
38}
39
40inline std::ostream&
41TestClassSTLContainersExt::streamOut( std::ostream& os ) const
42{
43 os << "m_list_of_double( " << m_list_of_double.size() << " ) :";
44 for ( std::list< double >::const_iterator i = m_list_of_double.begin();
45 i != m_list_of_double.end(); ++i ) {
46 os << " " << *i;
47 }
48 os << std::endl;
49 os << "m_deque_of_float( " << m_deque_of_float.size() << " ) :";
50 for ( std::deque< float >::const_iterator i = m_deque_of_float.begin();
51 i != m_deque_of_float.end(); ++i ) {
52 os << " " << *i;
53 }
54 return os;
55}
56
57inline bool
59{
60 // Check first the sizes of the containers
61 if ( m_list_of_double.size() != rhs.m_list_of_double.size() ) return false;
62 if ( m_deque_of_float.size() != rhs.m_deque_of_float.size() ) return false;
63
64 // Check element by element.
65 std::list< double >::const_iterator this_i_list_of_double = m_list_of_double.begin();
66 std::list< double >::const_iterator rhs_i_list_of_double = rhs.m_list_of_double.begin();
67 while ( this_i_list_of_double != m_list_of_double.end() ) {
68 if ( *this_i_list_of_double != *rhs_i_list_of_double ) return false;
69 ++this_i_list_of_double;
70 ++rhs_i_list_of_double;
71 }
72
73 std::deque< float >::const_iterator this_i_deque_of_float = m_deque_of_float.begin();
74 std::deque< float >::const_iterator rhs_i_deque_of_float = rhs.m_deque_of_float.begin();
75 while ( this_i_deque_of_float != m_deque_of_float.end() ) {
76 if ( *this_i_deque_of_float != *rhs_i_deque_of_float ) return false;
77 ++this_i_deque_of_float;
78 ++rhs_i_deque_of_float;
79 }
80
81 return true;
82}
83
84inline bool
86{
87 return ( ( (*this) == rhs ) ? false : true );
88}
89
90#endif
std::ostream & streamOut(std::ostream &os) const
TestClassSTLContainersExt()=default
bool operator!=(const TestClassSTLContainersExt &rhs) const
bool operator==(const TestClassSTLContainersExt &rhs) const