I need a data structure with the following properties:
- Access to elements must be very fast
- Elements, that are not added, shouldn't take memory (as ideal, size of empty structure near to zero)
- Each element has two integer coordinates (x,y) (access to elements only by them)
- Max count of elements known at creation time (over 10^3)
- Element contains few float values
It would be good if you also directed to an implementation of this structure in C or C++.
boost::unordered_map<pair<int,int>,Element>. I don't consider it particularly "purist" or "luxurious" to write C++ and use common C++ libraries, so a solution that has to work in both is more or less a C solution.