Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 dynamic arrays
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Homer_simpson




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Mon Aug 04, 2003 9:45 pm   Post subject: (No 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.
Catalyst




PostPosted: Mon Aug 04, 2003 10:16 pm   Post subject: (No 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?
Homer_simpson




PostPosted: Mon Aug 04, 2003 11:46 pm   Post subject: (No 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...
rizzix




PostPosted: Tue Aug 05, 2003 12:41 am   Post subject: (No 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
Homer_simpson




PostPosted: Tue Aug 05, 2003 1:31 am   Post subject: (No subject)

can u explain to me how vectors work?
Catalyst




PostPosted: Tue Aug 05, 2003 4:02 pm   Post subject: (No 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
Homer_simpson




PostPosted: Tue Aug 05, 2003 8:21 pm   Post subject: (No subject)

yes but i am still interested in knowing about vectors...
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Tue Aug 05, 2003 9:09 pm   Post subject: (No subject)

http://www.msoe.edu/eecs/ce/courseinfo/stl/vector.htm
Homer_simpson




PostPosted: Tue Aug 05, 2003 10:37 pm   Post subject: (No subject)

ah... ic...TY for the link man...
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: