For example:
#include <algorithm>
class CPanelInfos
{
. . .
bool AllGood( ) const
{
return std::all_of( DicIndexInfos.cbegin( ), DicIndexInfos.cend( ),
[]( auto p ) { return p.second.IsEqual; } );
}
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a map and would like to quickly check whether all entries are true. Are there any ready-made functions or approaches? In C# there is a LinQ query. IsAny. Is there something similar in C#? //-------------------------------------------------------------------
My code and thanks for help.
class CPCBInfos
{
public:
CPCBInfos() { IsEqual = true; SerialReadTop = ""; SerialReadBot = ""; };
~CPCBInfos() {};
CString SerialReadTop;
CString SerialReadBot;
bool IsEqual;
};
class CPanelInfos
{
public:
CPanelInfos() {};
~CPanelInfos() {};
map<CString, CPCBInfos> DicIndexInfos;
25-09-2024 13:23:02.071 [CUST] Position= 1, PanelIndex= 1, SideTop= 2024-09-25-0001, SideBottom= 2024-09-25-0001, Result= 1
25-09-2024 13:23:02.071 [CUST] Position= 2, PanelIndex= 2, SideTop= 2024-09-25-0002, SideBottom= 2024-09-25-0002, Result= 1
bool CPanelInfos::IsGood()
{
CPCBInfos value;
CString key;
bool ret = true;
// Create iterator
map<CString, CPCBInfos >::iterator itr;
// Iterator
for (itr = DicIndexInfos.begin(); itr != DicIndexInfos.end(); ++itr)
{
key = itr->first;
value = itr->second;
if (value.SerialReadTop == value.SerialReadBot)
value.IsEqual = true;
else
{
value.IsEqual = false;
ret = false;
}
}
return ret;
}
For example:
#include <algorithm>
class CPanelInfos
{
. . .
bool AllGood( ) const
{
return std::all_of( DicIndexInfos.cbegin( ), DicIndexInfos.cend( ),
[]( auto p ) { return p.second.IsEqual; } );
}
}