[mlpack-git] master: Properly use Enum type. (c82c747)

gitdub at mlpack.org gitdub at mlpack.org
Tue May 24 10:40:31 EDT 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/1f562a1aba7ae55475afcc95659511c2b7f694e5...5b8fdce471328f722fcd8c0f22a6d995ce22c98b

>---------------------------------------------------------------

commit c82c747a7fb8e0081f9185e199ce1611fe5d073a
Author: MarcosPividori <marcos.pividori at gmail.com>
Date:   Tue May 24 11:37:10 2016 -0300

    Properly use Enum type.


>---------------------------------------------------------------

c82c747a7fb8e0081f9185e199ce1611fe5d073a
 src/mlpack/methods/range_search/range_search_main.cpp | 2 +-
 src/mlpack/methods/range_search/rs_model.cpp          | 2 +-
 src/mlpack/methods/range_search/rs_model.hpp          | 8 ++++----
 src/mlpack/methods/rann/allkrann_main.cpp             | 2 +-
 src/mlpack/methods/rann/ra_model.hpp                  | 8 ++++----
 src/mlpack/methods/rann/ra_model_impl.hpp             | 6 +++---
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/mlpack/methods/range_search/range_search_main.cpp b/src/mlpack/methods/range_search/range_search_main.cpp
index 48fd2ed..3606950 100644
--- a/src/mlpack/methods/range_search/range_search_main.cpp
+++ b/src/mlpack/methods/range_search/range_search_main.cpp
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
     const string treeType = CLI::GetParam<string>("tree_type");
     const bool randomBasis = CLI::HasParam("random_basis");
 
-    int tree = 0;
+    RSModel::TreeTypes tree = RSModel::KD_TREE;
     if (treeType == "kd")
       tree = RSModel::KD_TREE;
     else if (treeType == "cover")
diff --git a/src/mlpack/methods/range_search/rs_model.cpp b/src/mlpack/methods/range_search/rs_model.cpp
index 7ffc97d..e0cdb18 100644
--- a/src/mlpack/methods/range_search/rs_model.cpp
+++ b/src/mlpack/methods/range_search/rs_model.cpp
@@ -14,7 +14,7 @@ using namespace mlpack::range;
  * Initialize the RSModel with the given tree type and whether or not a random
  * basis should be used.
  */
-RSModel::RSModel(int treeType, bool randomBasis) :
+RSModel::RSModel(TreeTypes treeType, bool randomBasis) :
     treeType(treeType),
     randomBasis(randomBasis),
     kdTreeRS(NULL),
diff --git a/src/mlpack/methods/range_search/rs_model.hpp b/src/mlpack/methods/range_search/rs_model.hpp
index a3827b5..9598981 100644
--- a/src/mlpack/methods/range_search/rs_model.hpp
+++ b/src/mlpack/methods/range_search/rs_model.hpp
@@ -33,7 +33,7 @@ class RSModel
   };
 
  private:
-  int treeType;
+  TreeTypes treeType;
   size_t leafSize;
 
   //! If true, we randomly project the data into a new basis before search.
@@ -69,7 +69,7 @@ class RSModel
    * @param treeType Type of tree to use.
    * @param randomBasis Whether or not to use a random basis.
    */
-  RSModel(const int treeType = TreeTypes::KD_TREE,
+  RSModel(const TreeTypes treeType = TreeTypes::KD_TREE,
           const bool randomBasis = false);
 
   /**
@@ -100,9 +100,9 @@ class RSModel
   size_t& LeafSize() { return leafSize; }
 
   //! Get the type of tree.
-  int TreeType() const { return treeType; }
+  TreeTypes TreeType() const { return treeType; }
   //! Modify the type of tree (don't do this after the model has been built).
-  int& TreeType() { return treeType; }
+  TreeTypes& TreeType() { return treeType; }
 
   //! Get whether a random basis is used.
   bool RandomBasis() const { return randomBasis; }
diff --git a/src/mlpack/methods/rann/allkrann_main.cpp b/src/mlpack/methods/rann/allkrann_main.cpp
index 6efb097..ce6f9f1 100644
--- a/src/mlpack/methods/rann/allkrann_main.cpp
+++ b/src/mlpack/methods/rann/allkrann_main.cpp
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
     const string treeType = CLI::GetParam<string>("tree_type");
     const bool randomBasis = CLI::HasParam("random_basis");
 
-    int tree = 0;
+    RANNModel::TreeTypes tree = RANNModel::KD_TREE;
     if (treeType == "kd")
       tree = RANNModel::KD_TREE;
     else if (treeType == "cover")
diff --git a/src/mlpack/methods/rann/ra_model.hpp b/src/mlpack/methods/rann/ra_model.hpp
index fffdb58..a04107f 100644
--- a/src/mlpack/methods/rann/ra_model.hpp
+++ b/src/mlpack/methods/rann/ra_model.hpp
@@ -45,7 +45,7 @@ class RAModel
 
  private:
   //! The type of tree being used.
-  int treeType;
+  TreeTypes treeType;
   //! The leaf size of the tree being used (useful only for the kd-tree).
   size_t leafSize;
 
@@ -79,7 +79,7 @@ class RAModel
    * Initialize the RAModel with the given type and whether or not a random
    * basis should be used.
    */
-  RAModel(int treeType = TreeTypes::KD_TREE, bool randomBasis = false);
+  RAModel(TreeTypes treeType = TreeTypes::KD_TREE, bool randomBasis = false);
 
   //! Clean memory, if necessary.
   ~RAModel();
@@ -132,9 +132,9 @@ class RAModel
   size_t& LeafSize();
 
   //! Get the type of tree being used.
-  int TreeType() const;
+  TreeTypes TreeType() const;
   //! Modify the type of tree being used.
-  int& TreeType();
+  TreeTypes& TreeType();
 
   //! Get whether or not a random basis is being used.
   bool RandomBasis() const;
diff --git a/src/mlpack/methods/rann/ra_model_impl.hpp b/src/mlpack/methods/rann/ra_model_impl.hpp
index 72f083b..48b4b4a 100644
--- a/src/mlpack/methods/rann/ra_model_impl.hpp
+++ b/src/mlpack/methods/rann/ra_model_impl.hpp
@@ -14,7 +14,7 @@ namespace mlpack {
 namespace neighbor {
 
 template<typename SortPolicy>
-RAModel<SortPolicy>::RAModel(const int treeType, const bool randomBasis) :
+RAModel<SortPolicy>::RAModel(const TreeTypes treeType, const bool randomBasis) :
     treeType(treeType),
     leafSize(20),
     randomBasis(randomBasis),
@@ -377,13 +377,13 @@ size_t& RAModel<SortPolicy>::LeafSize()
 }
 
 template<typename SortPolicy>
-int RAModel<SortPolicy>::TreeType() const
+typename RAModel<SortPolicy>::TreeTypes RAModel<SortPolicy>::TreeType() const
 {
   return treeType;
 }
 
 template<typename SortPolicy>
-int& RAModel<SortPolicy>::TreeType()
+typename RAModel<SortPolicy>::TreeTypes& RAModel<SortPolicy>::TreeType()
 {
   return treeType;
 }




More information about the mlpack-git mailing list