The main function of the program is to copy files from folder to folder on the server by looping through each file in the source folder in a loop. And there is a task for the function to accept the exception files, that is, not to copy them. I stored the exceptions in a vector. And the question arises how to quickly find the correspondence between the vector element and the file being processed. This method works, but it heavily loads the CPU, since it is inside the main function loop.
if (!except.empty()) { except_it = except.begin(); while (except_it != except.end()) { if (ps.filename() == *except_it) { // ps.filename() - имя файла ++it_source; // *except_it - имя файла исключения ++except_it; break; } }
find-linear search algorithm. As you have already been advised, you can use other types of containers ... but something is all strange. Such a simple search should not overload the processor. What is your real size vector of exceptions? The fact is that yes, other containers will provide asymptotics faster, but they usually have a larger coefficient inO(). so for small sizes the vector is usually preferred. In short, see if the problem is exactly in this - linear search. - Harry