Jump to content
  • Advertisement
Sign in to follow this  
Sigutis

c++ pointer to pointer to pointer to pointer

This topic is 3835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Have any of you found any practical use of **** - pointer to pointer to pointer to pointer? If you did probably to confuse anyone reading your code. Or else?

Share this post


Link to post
Share on other sites
Advertisement
A linked list is a 'Node **********...*node'.

Quote:
If you did probably to confuse anyone reading your code.


Such syntax makes me want to do painful things to the author of the code.

Share this post


Link to post
Share on other sites
A four-dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice, in order to avoid potential memory leaks.

Either way, the usage syntax is not confusing beyond the allocation stage. One can use array notation for either pointer or vector cases, ex: lattice[t][x][y][z].whatever = 0;

**** Edit: See sneftel's response below (and my response to that) for a better solution.

[Edited by - taby on June 11, 2008 12:18:07 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by taby
A four dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice.


vector<type>, with appropriate subscripting, would be an even better choice. Simulating multidimensional grids with nested one-dimensional containers is inefficient and wasteful.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
Quote:
Original post by taby
A four dimensional lattice to simulate quantum chromodynamics -- http://en.wikipedia.org/wiki/Lattice_QCD

However, vector<vector<vector<vector<type>>>> lattice; might be a better choice.


vector<type>, with appropriate subscripting, would be an even better choice. Simulating multidimensional grids with nested one-dimensional containers is inefficient and wasteful.


Ah yes, good point.

In that case, it would work out to something like:

vector<type> lattice;
lattice.resize(t_size*x_size*y_size*z_size);

size_t index = t*x_size*y_size*z_size + x*y_size*z_size + y*z_size + z;

lattice[index].whatever = 0;

It's been a while since I've done anything like this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!