C++, MFC, check two list, best way

Markus Freitag 3,791 Reputation points
2021-11-06T16:48:09.463+00:00

Hello,
I have a default list and must check whether all values are contained in my dictionary map.

147041--compare-lists-001.png

A) Are all default values available in my dictionary? Yes or no?

B) Are all the default values exactly in my dictionary? It has to be exactly the same.

How can I best solve the problem. With map, dictionary, vector or something else

Thanks in advance for examples.

Developer technologies | C++
Developer technologies | .NET | .NET CLI
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 49,536 Reputation points
    2021-11-07T13:45:54.247+00:00

    If the EAN code is used as a key then for a .Net Dictionary you can use the ContainsKey method and in a Standard C++ library map object you could use the find method

    1 person found this answer helpful.
    0 comments No comments

  2. Petrus 【KIM】 546 Reputation points
    2021-11-18T07:14:10.627+00:00

    How about ...

    ATL::CAtlList<int> oValueList;
    ATL::CAtlMap<int, int> oValueCountMap;

    int nCount = oValueCountMap.Find(1234567890);

    When you create the "Current List, Dictionary" with std::map or ATL::CAtlMap,
    just count, how many value in that.
    Then insert or add the key(value) and Count to "oValueCountMap"...

    You can find the count.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.