I have a list of files (C is stored as string strings) that I'm searching for and I Will people remove files that do not match my criteria What is the best container to use for this purpose? I'm thinking now set as the note that the list of files will never be bigger when it is started. I'm only removing from the container.
I definitely will not use a set - t needs to be sorted so that any set There is no point in using. The set is applied as a self-equating tree, and self-balance algorithms are unnecessary in your case.
If you are going to do this operation once, then with a std :: vector removal (from & lt; algorithm>), after erasing one. If you have not used the previously extracted_fifthment, then overwriting irrelevant ones in the process, what it does and pulls all relevant objects down. To reduce the size of a vector, you have to erase it. Like:
std :: vector & lt; Const char * & gt; Files; Files.erase (remove_if (files.begin (), files.end (), RemovePredicate ()), files.end ());
If you want to take advantage of your O (1) extinction time property, writing code to do the same thing with the std :: list will be a bit more difficult. As you are doing only this one-off operation, which will take you so much time, you will not even pay attention to this, I recommend doing this because it is the easiest way.
And honestly, I do not think you'll see a lot of difference in the speed between std :: list and std :: vector approach. The vector approach only copies each value once, it is actually very fast, still takes very little space in my opinion, going up to a std :: list and using three spaces only is really justified if You are going to add a lot of extra in the life of the whole app.
Comments
Post a Comment