Computer Science Canada dynamic arrays |
Author: | Homer_simpson [ Mon Aug 04, 2003 7:58 pm ] |
Post subject: | dynamic arrays |
i know i can create arrays like this: int *var; var = new int[1000]; but how can i create an array with unknown size and add to it whenever i need? |
Author: | rizzix [ Mon Aug 04, 2003 9:45 pm ] |
Post subject: | |
u can't u might need to use a Vector. i don't know much about vectors in c++. but in java thats what we use. |
Author: | Catalyst [ Mon Aug 04, 2003 10:16 pm ] |
Post subject: | |
well if ur working with something that needs very high speeds (like gfx) vectors might be too slow for ur needs another method of making a temporay array and transfering it all over would also be too slow is there ne more specific that might help in finding the solution that you can provide? |
Author: | Homer_simpson [ Mon Aug 04, 2003 11:46 pm ] |
Post subject: | |
well... there's a method i learned long ago back when i was using pascal... i create a structure hold 3 values : previous,value,next previous hold the pointer to the previous structure and next hold the pointer to the next and value is the value... i was gonna need arrays to hold my textures... i think this method is gonna work just fine...and i can load new textures at any time... |
Author: | rizzix [ Tue Aug 05, 2003 12:41 am ] |
Post subject: | |
btw the method ur talking about is known as LinkedLists, i'm not sure if it is a lot more faster. but i'm pretty sure vectors are pretty fast. you could modify the buffer size of the vector to improve performance |
Author: | Homer_simpson [ Tue Aug 05, 2003 1:31 am ] |
Post subject: | |
can u explain to me how vectors work? |
Author: | Catalyst [ Tue Aug 05, 2003 4:02 pm ] |
Post subject: | |
linked lists should be fine for textures (i thought u might be using them for verticies and such where they would be far too slow) if u want to save ur self some trouble u can use the standard list class std::list it has a lot of good features and is painless to implement |
Author: | Homer_simpson [ Tue Aug 05, 2003 8:21 pm ] |
Post subject: | |
yes but i am still interested in knowing about vectors... |
Author: | Catalyst [ Tue Aug 05, 2003 9:09 pm ] |
Post subject: | |
http://www.msoe.edu/eecs/ce/courseinfo/stl/vector.htm |
Author: | Homer_simpson [ Tue Aug 05, 2003 10:37 pm ] |
Post subject: | |
ah... ic...TY for the link man... |