C++ (Qt)struct CBigClass {... QList<CData> mData; QSet<CData *> mSelection; ...};
C++ (Qt)void CBigClass::SomeMethod( void ) { .. for (auto & data : mData) { ... }}
C++ (Qt)void CBigClass::SomeMethod2( void ) { .. for (auto it : mSelection) { ... }}
C++ (Qt)void CBigClass::SomeMethod( bool useSelection ) { .. int limit = useSelection ? mSelection.size() : mData.size(); auto dataIt = mData.begin(); auto selIt = mSelection.begin(); for (int i = 0; i < limit; ++i) { CData * dataPtr; if (useSelection) { dataPtr = *selIt; ++selIt; } else { dataPtr = &(*dataIt); ++dataIt; } ... }}
C++ (Qt)template<class Iter>CData & DataRef( Iter & it ){ return *it;} CData & DataRef( QSet<CData *>::iterator & it ){ return *(*it);}
C++ (Qt)template<class Container>void CBigClass::SomeMethod( Container & container ) { ... for (auto it = container.begin(); it != container.emd(); ++it) { CData & data = DataRef(it); ... }}
C++ (Qt)template<class T>CData & DataRef( T & ref ) { return ref; } CData & DataRef( CData *& refPtr ) { return *refPtr; }