[QUOTE=Jallen;18718355]What is with the love of old interfaces? It looks like shit, move on.[/QUOTE]
Exactly what I thought. IMO classic looks crap.
[QUOTE=nullsquared;18717338]Yeah, there's no good point in using a list unless you [i]know[/i] you will specifically benefit from what it offers over a vector.[/QUOTE]
TBH the only reason I was using a list was because it makes removing easier.
[QUOTE=garry;18718426]TBH the only reason I was using a list was because it makes removing easier.[/QUOTE]
Here's a snippet of what I use to manage lists in a state thing..
[cpp] //! Adds a child to the state.
void addChild(CState* child)
{
children.push_back(child); // Add the child to the children array.
}
//! Removes a child from the state.
//! @return Returns true if there was an error.
bool removeChild(CState* child)
{
bool pushBack = false; // Is it pushing back the number of children because it removed one in the middle of the array?
for(unsigned int i = 0; i < children.size(); i++) // Loop through all the children.
{
if(pushBack == true) // If a child has been found and now it's pushing children back so the array is all nice and neat.
children[i - 1] = children[i];
if(children[i] == child) // If the child has been found.
{
child->removeParent(); // Remove the parent reference.
children[i] = 0;
pushBack = true; // Push back all the other children to cover the empty space.
}
}
if(pushBack == true && children.size() != 1) // If the array isn't one child, remove the extra one that wasn't pushed back.
children.pop_back();
return pushBack != true; // Pushing back stuff means it found the child.
}
...
vector<CState*> children; ///< Its children.[/cpp]
Don't vectors deal with all that for you?
Vectors are vectors. You can only remove stuff from the front and back.
I'm working on a Java program that makes particles, with minds of their own. They act differently according to their surroundings. Ofcourse, the first feature I implemented was an imploding time bomb to kill them all.
[QUOTE=Eleventeen;18718619]Vectors are vectors. You can only remove stuff from the front and back.[/QUOTE]
Use a list then?
Also what happens if child is in said vector more than once?
std::vector does have a erase-function, accepting either an index or two iterators to delete either one specific element or a sequence.
std::list erases faster than std::vector though, unless it is the last element [citation needed].
Re-writing the plugin core for Mani Admin 2.0. Currently writing the MMS interface callbacks.
[QUOTE=bean_xp;18718702]Use a list then?
Also what happens if child is in said vector more than once?[/QUOTE]
I forgot to do error checking? What is your point?
[QUOTE=Eleventeen;18718619]Vectors are vectors. You can only remove stuff from the front and back.[/QUOTE]
what are you doing
[QUOTE=efeX;18718971]what are you doing[/QUOTE]
No need to call me names if I made a MISTAKE.
[QUOTE=Eleventeen;18719001]No need to call me names if I made a MISTAKE.[/QUOTE]
Well do you understand that you can remove from any part of a vector?
[QUOTE=garry;18718426]TBH the only reason I was using a list was because it makes removing easier.[/QUOTE]
[cpp]
typedef std::vector<someType> vec_t;
vec_t someVec;
// ...
someVec.erase(someVec.begin() + 5);
// ...
for (vec_t::iterator i = someVec.begin(); i != someVec.end(); /* no inc */)
{
if (wantToRemove)
i = someVec.erase(i);
else
++i;
}
[/cpp]
[QUOTE=garry;18713935]What's the best way to divide a std::list into, say, 10 smaller std::lists?[/QUOTE]
Use a skip list.
[QUOTE=Cathbadh;18720272]Use a skip list.[/QUOTE]
Elaborate.
PSH. All you guys using std::vector.
Real men use a deque :v:
Real men write their own containers in C99
[QUOTE=nullsquared;18720316]Elaborate.[/QUOTE]
It's basically a contiguous heirarchy of lists? E.g. a list of lists, or a list of lists of lists. There's a wikipedia page.
So you have your normal base-level linked list. You make a new linked list (the first-level list) with data fields that form pointers to certain sporadic entries in the base-level list. By convention, this doesn't change the base-level list at all, but if you want to it is certainly very simple to chop up a linked list into several smaller lists
[QUOTE=blankthemuffin;18720397]Real men write their own containers in C99[/QUOTE]
And they use a goto. While drunk. Then wake up the next day realize what they did, and fix it.
Based on a true story
The More You Know --==☆
[QUOTE=Chandler;18720621]And they use a goto. While drunk. Then wake up the next day realize what they did, and fix it.
Based on a true story
The More You Know --==☆[/QUOTE]
We all do regretable things while inebreated.
[QUOTE=Cathbadh;18720767]We all do regretable things while inebreated.[/QUOTE]
I know, right? This one time I used a variable of type double instead of float, even though float had sufficient precision for the task at hand.
Boy, was [I]that [/I]a crazy night... :frogsiren:
:v:
[QUOTE=Jallen;18721521]I know, right? This one time I used a variable of type double instead of float, even though float had sufficient precision for the task at hand.
Boy, was [I]that [/I]a crazy night... :frogsiren:
:v:[/QUOTE]
That's what you get for compiling with -pedantic! :v:
EDIT: OR whatever!
The worst thing is that you're drunk and inside on your own.
[QUOTE=blankthemuffin;18726134]The worst thing is that you're drunk and inside on your own.[/QUOTE]
yeah only cool people are outside when they're drunk
[QUOTE=efeX;18726348]yeah only cool people are outside when they're drunk[/QUOTE]
At this time of year they definitely will be cool.
[QUOTE=nullsquared;18720235][cpp]
typedef std::vector<someType> vec_t;
vec_t someVec;
// ...
someVec.erase(someVec.begin() + 5);
// ...
for (vec_t::iterator i = someVec.begin(); i != someVec.end(); /* no inc */)
{
if (wantToRemove)
i = someVec.erase(i);
else
++i;
}
[/cpp][/QUOTE]
I'm using this, haven't profiled it but I always trust their code to be faster than anything I could write :x
[cpp]
template <typename T, typename U>
void VectorRemove( std::vector<T>& vec, const U& var )
{
vec.erase( std::remove( vec.begin(), vec.end(), var ), vec.end() );
}
[/cpp]
[editline]10:17AM[/editline]
Made a little profiler class..
[img]http://filesmelt.com/downloader/04Dec2009_001.jpg[/img]
Bitmap renderer that some guy gave to me has been refit into C++ code using classes and crap.
[img]http://i50.tinypic.com/2gwcp03.png[/img]
[img]http://img.loldepot.com/c83ced0cba27ca219d5e3.png[/img]
Decent user interface? Or did I add a bit too much on one item?
[QUOTE=Diaklu;18727308]Decent user interface? Or did I add a bit too much on one item?[/QUOTE]
Small white text on bright green isn't exactly my cup of tea, especially as a small icon overlay; and the interface looks somewhat crowded I think.
My advice is to minimize information displayed by default and move the details to user-drawn tool-tips or a separate panel that displays information for the selected item.
Sorry, you need to Log In to post a reply to this thread.