【发布时间】:2018-03-31 13:52:04
【问题描述】:
我想创建一个等效的数据结构,我在 python 的 C++ 赋值中使用。我很难弄清楚如何做到这一点。结构如下 -
map < string, map < string, vector < int > > > invertedIndex;
你能指出我正确的方向吗?
编辑:我知道 list 和 dict 分别是 vector 和 map 的等价物,我应该指定是否有单行代码可以在 python 中初始化相同的数据结构。
【问题讨论】:
-
map = dict, vector = list,够吗? -
没错,你想要一个有序的地图,还是只是一个无序的地图?
-
为什么任何编程语言都有一个完全等同于
map<string,map<string,vector<int>>>的数据结构? 当然你必须用嵌套的字典和列表来构建它。
标签: python c++ python-3.x data-structures