开发者

How to read from dictionary?

开发者 https://www.devze.com 2023-04-05 04:31 出处:网络
I have a dictionary as follows: static Dictionary<String ^, List<String ^>^> ^ language_strin开发者_开发问答g_table;

I have a dictionary as follows:

static Dictionary<String ^, List<String ^>^> ^ language_strin开发者_开发问答g_table;

Where I have 17 strings. For each of 17 strings there is an associated list of 1500 strings. Now what i want to do is: compare strings in all the lists at each and every index.

e.x. 1st list 1st element should be compared with all the list's 1st element. Similarly for all the indexes in all the lists.


Why not use loops?

    for each(KeyValuePair<String^ , List<String^>^> pair1 in qwe)
    {
        for each(KeyValuePair<String^ , List<String^>^> pair2 in qwe) 
        {
            if(! pair1.Key->Equals(pair2.Key))
            {
                for(int i = 0; i< 1500; ++i)
                {
                    SomeCompareFunction(pair1.Value[i],pair2.Value[i]) 
                }
            }
        }
    }


You can compare 2 Lists with Enumerable::SequenceEqual:

List<String^>^ list1 = ...;
List<String^>^ list2 = ...;
bool equal = Enumerable::SequenceEqual(list1, list2);

You only have to iterate over the dictionary values and compare it as above.

0

精彩评论

暂无评论...
验证码 换一张
取 消