From 6b5154968526100f7420f10c429252eab9e9222a Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Sun, 19 Jun 2011 14:40:41 +0200
Subject: [PATCH] ENH: change list to vector

---
 Code/Core/otbWrapperParameterGroup.cxx | 25 +++++++++++--------------
 Code/Core/otbWrapperParameterGroup.h   |  2 +-
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/Code/Core/otbWrapperParameterGroup.cxx b/Code/Core/otbWrapperParameterGroup.cxx
index 7568b05c98..47bf4a8121 100644
--- a/Code/Core/otbWrapperParameterGroup.cxx
+++ b/Code/Core/otbWrapperParameterGroup.cxx
@@ -43,41 +43,38 @@ ParameterGroup::~ParameterGroup()
 {
 }
 
-std::list<std::string>
-ParameterGroup::GetParametersKeys()
+std::vector<std::string>
+ParameterGroup::GetParametersKeys(bool recursive)
 {
-  std::list<std::string> parameters;
+  std::vector<std::string> parameters;
 
   ParameterListType::iterator pit;
   for (pit = m_ParameterList.begin(); pit != m_ParameterList.end(); ++pit)
     {
     Parameter* param = *pit;
-    if (dynamic_cast<ParameterGroup*>(param))
+    parameters.push_back( param->GetKey() );
+
+    if (recursive && dynamic_cast<ParameterGroup*>(param))
       {
       ParameterGroup* paramAsGroup = dynamic_cast<ParameterGroup*>(param);
-      std::list<std::string> subparams = paramAsGroup->GetParametersKeys();
-      for (std::list<std::string>::const_iterator it = subparams.begin();
+      std::vector<std::string> subparams = paramAsGroup->GetParametersKeys();
+      for (std::vector<std::string>::const_iterator it = subparams.begin();
            it != subparams.end(); ++it)
         {
         parameters.push_back( std::string(paramAsGroup->GetKey()) + "."  + *it );
         }
       }
-    else if (dynamic_cast<ChoiceParameter*>(param))
+    else if (recursive && dynamic_cast<ChoiceParameter*>(param))
       {
       ChoiceParameter* paramAsChoice = dynamic_cast<ChoiceParameter*>(param);
-      parameters.push_back( param->GetKey() );
 
-      std::list<std::string> subparams = paramAsChoice->GetParametersKeys();
-      for (std::list<std::string>::const_iterator it = subparams.begin();
+      std::vector<std::string> subparams = paramAsChoice->GetParametersKeys();
+      for (std::vector<std::string>::const_iterator it = subparams.begin();
            it != subparams.end(); ++it)
         {
         parameters.push_back( std::string(paramAsChoice->GetKey()) + "."  + *it );
         }
       }
-    else
-      {
-      parameters.push_back( param->GetKey() );
-      }
     }
   return parameters;
 }
diff --git a/Code/Core/otbWrapperParameterGroup.h b/Code/Core/otbWrapperParameterGroup.h
index 9a58ac149b..bfdde995ff 100644
--- a/Code/Core/otbWrapperParameterGroup.h
+++ b/Code/Core/otbWrapperParameterGroup.h
@@ -59,7 +59,7 @@ public:
 
   unsigned int GetNumberOfParameters();
 
-  std::list<std::string> GetParametersKeys();
+  std::vector<std::string> GetParametersKeys(bool recursive = true);
 
 protected:
   ParameterGroup();
-- 
GitLab