Jump to content

  • Log In with Google      Sign In   
  • Create Account


Array MADNESS


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 09:47 AM

Ok if I want to make a stack of arrays that i am going to update constantly in both element amount as well as individual elements what would be the best way of going about this? so I need a dynamic array of containers holding 16 element arrays that i am going to update constantly. also if i was going to use a dynamic array thats not a vector how would i go about updating the size of that array. but im not against using vectors either just incase some one wants to share an example of that.

 

so i need to declare new array for each call of the render callback, populate that array then push it onto a stack of arrays and then do it again on that same render callback pass if i have more then one array that i have stacked. and i will be potentially adding to that stack every time new object is introduced to my scene. 

 

so

 

renderCallbackLOOP(){

 

//create dynamic array of 16 element arrays

 

//add newArray to my personal stack

 

//dostuff to newArray

 

//cycle to next newArray in my personal stack do stuff to it

 

}


J-GREEN

Greenpanoply

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 11701

Like
7Likes
Like

Posted 18 March 2013 - 09:49 AM

I don't know if you mean this "MADNESS" thing in the subject as a joke or something, but it's getting old. Please, supply your questions with more reasonable titles, or I will stop reading them.

Edited by Álvaro, 18 March 2013 - 09:49 AM.


#3 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 10:00 AM

Its not a joke I just wanted to post a question particularly about arrays and I just usually include that in my titles. I promise I am not trying to offend any one. I do apologize for recently posting so many questions I am just trying to wrap my mind around a problem that has been plaguing me for a few days now.


J-GREEN

Greenpanoply

#4 BitMaster   Crossbones+   -  Reputation: 3576

Like
0Likes
Like

Posted 18 March 2013 - 10:23 AM

Posting many questions is not the issue. Posting questions of the form "<something> MADNESS" is just annoying and starting to get obnoxious. If nothing else, at least name it "Array question", though a more descriptive title is preferred.

#5 BCullis   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 18 March 2013 - 10:24 AM

This has some code smells to it, what's the context of these arrays of 16 elements?  Do they contain 16 points of data that the renderer uses to draw the object?

 

Use the STL, it has multiple data structures templated for you that will handle dynamic sizing.  Vector, Queue, etc.


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#6 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 10:28 AM

Ok I promise i wont include "MADNESS" in my tittles any longer. Now, can some one please address the question? I mean its a legit question.  I am not looking for a Matrix library and I am not using STL. I am looking for just generic code responses for a dynamic array implementation.


Edited by greenzone, 18 March 2013 - 10:30 AM.

J-GREEN

Greenpanoply

#7 BCullis   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 18 March 2013 - 10:41 AM

but im not against using vectors either just incase some one wants to share an example of that

Is at odds with

and I am not using STL

 

At any rate, array size is immutable.  If you want to dynamically size an array, you build a new one with the new size, copy the old contents in, add any new data to the expanded space, and then delete the old array.


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#8 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 10:54 AM

wait im sorry i miss understood. yes the stl vector would be fine but how would you recomend i set up each array in that vector. I mean do i create the vector for each array then push that vector onto the main vector? I was thinking SDL when i read your post sorry again.


Edited by greenzone, 18 March 2013 - 10:59 AM.

J-GREEN

Greenpanoply

#9 Álvaro   Crossbones+   -  Reputation: 11701

Like
0Likes
Like

Posted 18 March 2013 - 11:00 AM

Let me get this right. You are trying to program a "dynamic array" in C++, but you are not using standard containers. Well, the answer is then "Use standard containers". They are there for a reason.

#10 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 11:02 AM

Again, I apologize i thought read SDL. should i just repost my question again, with out using "MADNESS" of course' so Most of the thread is not subject so massive miss understanding?


Edited by greenzone, 18 March 2013 - 11:03 AM.

J-GREEN

Greenpanoply

#11 BCullis   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 18 March 2013 - 11:04 AM

Rawest form: create a vector of pointers, each pointer being the head of an individual array of data.

Somewhat better: create a vector of vectors, where the "outer layer" vector is the dynamically-sized group, comprised of 16-element vectors (instead of your 16-element arrays).  The way you describe it in your latest reply is correct in that regard, in that you would take the 16 elements, push them into a vector, and then push THAT vector onto the "main" one.

OOD approach: wrap the arrays of information in a struct or class, and just create a vector of said classes.

 

My question still stands though: what is this being used for?  It feels very unconventional, and there might be a more programmer-friendly approach that I could suggest if I knew what was going on.


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#12 greenzone   Members   -  Reputation: 672

Like
0Likes
Like

Posted 18 March 2013 - 11:08 AM

thank you BCullis, I particularly appreciate the OOD suggestion and think that might actually be the approach i am looking for.


J-GREEN

Greenpanoply




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS