Dear All:
I want to build a 3D Euclidean space by using an index accessible class like
Code:
3DSpace<T*> my_space[1000][1000][1000];
my_space[100][50][25] = ....;
The space should be able to contain more than 1 million gridpoints although most of them will be NULL. Here I am looking for a method which can allocate memory for the gridpoints with content and meantime do not allocate memory for those gridpoints which are NULL. As this is probably the only way to hold such a large data space. For example:
Code:
T* grid_point;
my_space[100][50][25] = grid_point;
T* get_point = my_space[0][0][0];
// here get_point should give a NULL pointer. As (0,0,0) is not given a value.
I tried the STL library hash_map, but the drawback of the hash_map is:
Code:
hash_map<int, float> my_hash;
my_hash[0] = 10.5;
cout << "size of my_hash=" << my_hash.size() << endl;
// This gives: size of my_hash=1;
float get_number = my_hash[10];
// obviously this should throw an exception as my_hash[10] is not given a value.
// But the hash_map doesn't throw an exception and increases the size of the container
cout << "size of my_hash=" << my_hash.size() << endl;
// this gives: size of my_hash=2;
This is a really bizarre behaviour which is definitely not what I wanted.
Does anyone have any idea to help me with this problem please?
Thanks
Merry Christmas!!!
[/code]