Question

I am working on a piece of code that need to do something very similar to the combine function in ArcGIS in C/C++. See: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Combining%20multiple%20rasters

The C++ code will read in multiple very large raster data files (2GB+) in chunks, find unique combinations and output to a single map. For example, if there were 3 maps and <1,3,5> existed, respectfully, in the first cell of the three maps then I want all subsequent instances of <1,3,5> to have the same key in the final output map.

What STL containers should I be using to store the maps? Reading in the files in chunks certainly adds more complexity of the project. The algorithm needs to be very fast so I cannot use vectors which have a O(n) complexity for searching. Currently, I'm thinking of using a unsorted_map of unsorted_multimaps but I am not sure if this is correct and if I am going to get the performance I need.

Any thoughts?

Was it helpful?

Solution

Yes, std::map or std::unordered_map is correct choice. unordered_map is faster and more compact if you don't need order. If you need something even faster, you can replace it with other map implementation.

Use something compact for the key, something like std::tuple or std::array.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top