Translating python dictionary to C++

前端 未结 7 1057
-上瘾入骨i
-上瘾入骨i 2020-11-30 00:57

I have python code that contains the following code.

d = {}

d[(0,0)] = 0
d[(1,2)] = 1
d[(2,1)] = 2
d[(2,3)] = 3
d[(3,2)] = 4

for (i,j) in d:
    print d[(         


        
7条回答
  •  盖世英雄少女心
    2020-11-30 01:27

    Map is often implemented as a balanced binary tree not a hash table. This not the case for a Python dict. So you need a C++ O(1) equivalent data structure to use your pairs with.

提交回复
热议问题