Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / List iterator headaches

Author
Message
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 11th Dec 2010 16:41
Hey everybody, I've decided to give DGDK another try now that it's been officially updated to support VS2010. I've recently been trying to make a "find free object()"(from the Matrix1Utils) type of function/class utilizing std::list, but I've hit a roadblock.

Here's my function:


This works fine in the fact that it generates a linear list of numbers at first. What I also want it to do is fill any "holes" in the list made by the list members being deleted. It's having some problems doing that, such as I'll call this function 11 times at first, then delete the elements 2,5,10. Somehow, the variable tmp never equals 4, it always skips to 6 which prevents the hole from getting fixed.

Here's my whole main.cpp


Any help would be greatly appreciated.


_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 11th Dec 2010 18:21
Do you really want to do this using std::list? Why not do something like this:



Much easier. Well, if you have lots of objects with following IDs the loop may take some time, but your std::list approach seems a bit overhead to me. But maybe you have your reasons to do so, don't know.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 11th Dec 2010 18:30
I totally forgot about that function. I'm going to have to rethink my approach to this. Probably going to end up doing a bit of both, might need the list for something else later on. Thanks for the help _Pauli_


_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 11th Dec 2010 19:41
You're welcome.

Quote: "might need the list for something else"


Yeah, I find std::list very useful for all kinds of data collections (object/media management etc.).

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.

Login to post a reply

Server time is: 2024-11-19 16:46:12
Your offset time is: 2024-11-19 16:46:12