【发布时间】:2014-03-22 01:45:12
【问题描述】:
Consier 我有一些桶 (vector<float>)。我需要根据一些索引访问这个存储桶。示例:
int indexX, indexY, indexZ, indexW;
因此,当一个新点到达时,我需要将该点放入正确的存储桶中。现在我正在做这样的事情:
// X Y Z W => Bucket
unordered_map<int, unordered_map<int, unordered_map<int, unordered_map<int, vector<float>>>>> indexedTable;
// New point arrives and I put it in the right bucket:
indexedTable[indexX][indexY][indexZ][indexW].push_back(myValue);
但我觉得这很丑陋,而且很遗憾它也很慢。比如访问1700点,需要0.56秒,太慢了。
在不使用 Boost 的情况下,有没有更好/更快的替代方案?
请注意,我需要的这种数据结构与稀疏矩阵(多维)相当,因为很少有“桶”会被填充。
【问题讨论】: