|
a dynamic array of pointers
for my sprite system i''m making a dynamic array. since the bitmap type has to be a pointer is has to be a pointer to a pointer. here is my code that adds a frame to the end of the array:
whats the best way of adding an item to a dynamic array (of pointers )?
thanks
thomas
-----------------------------
-cow_in_the_well
''When in doubt, empty your magazine.'' - Murphy''s Combat Law
- Thomas Cowellwebsite | journal | engine video
maybe there are more opportunities,but what about linked lists?!
Edited by - castor on January 20, 2001 1:33:53 PM
Edited by - castor on January 20, 2001 1:33:53 PM
I don''t know that linked lists are appropriate. I presume that when you create this container of frames, you''d be doing it all at once and in-order. That is, you aren''t going to be inserting or deleting frames from anywhere but the end of the list. Since the list is a list of 32-bit pointers, which are really small and easy to move, you should be able to do it with an STL vector.
There''s no need to store the frame count--that''s m_bmpVec.size (). If you want to loop through the bitmaps, just do this:
|
There''s no need to store the frame count--that''s m_bmpVec.size (). If you want to loop through the bitmaps, just do this:
for (int i=0; ibmpVec.size (); i++){ jiBitmap *frame = Sprite->bmpVec; // do whatever you want with frame}
erfff....been away a few days and had to dig to find this again
anyway...
castor: i just thought that linked lists would be overkill, im just adding to the end not pulling from the middle and i didn''t want to have to search through from the beginning to find a certain frame.
Stoffel: that looks really cool, i should look into the STL a bit more . anyway i fixed my function up so it does it manually. I had just forgotten to copy the bitmap pointers from the old to the new lists.
works so i won''t bother change it
thanks
-----------------------------
-cow_in_the_well
''When in doubt, empty your magazine.'' - Murphy''s Combat Law
anyway...
castor: i just thought that linked lists would be overkill, im just adding to the end not pulling from the middle and i didn''t want to have to search through from the beginning to find a certain frame.
Stoffel: that looks really cool, i should look into the STL a bit more . anyway i fixed my function up so it does it manually. I had just forgotten to copy the bitmap pointers from the old to the new lists.
|
works so i won''t bother change it
thanks
-----------------------------
-cow_in_the_well
''When in doubt, empty your magazine.'' - Murphy''s Combat Law
- Thomas Cowellwebsite | journal | engine video
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement