From cd7cbbb5bdb7ad986136d36eb98bb3d93764bd76 Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Fri, 30 Dec 2011 17:20:53 +0100 Subject: [PATCH] BUG: std::unique actually only removes consecutive equal elements --- .../otbWrapperApplicationRegistry.cxx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx b/Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx index 43ea6ffb13..b92d4ba243 100644 --- a/Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx +++ b/Code/ApplicationEngine/otbWrapperApplicationRegistry.cxx @@ -132,22 +132,20 @@ ApplicationRegistry::GetAvailableApplications() } } - // Return the app list - std::vector<std::string> availableApp; + // Get all the app names + // If ITK_AUTOLOAD_PATH contains several times the same path, then the same app appear several times + // Use a temporary std::set to fix this + std::set<std::string> appSet; for(std::list<ApplicationPointer>::iterator k = possibleApp.begin(); k != possibleApp.end(); ++k) { (*k)->Init(); - availableApp.push_back((*k)->GetName()); + appSet.insert((*k)->GetName()); } - // If the ITK_AUTOLOAD_PATH contains - // several times the same path, application will appears several - // times in the list.To be cleaner, we erase multiple - std::vector<std::string>::iterator it; - it = std::unique(availableApp.begin(), availableApp.end()); - availableApp.resize( it - availableApp.begin() ); - - return availableApp; + + std::vector<std::string> appVec; + std::copy(appSet.begin(), appSet.end(), std::back_inserter(appVec)); + return appVec; } -- GitLab