[mlpack-svn] r17048 - mlpack/trunk/src/mlpack/core/tree/rectangle_tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sun Aug 17 01:00:05 EDT 2014
Author: rcurtin
Date: Sun Aug 17 01:00:05 2014
New Revision: 17048
Log:
Simplify some loops.
Modified:
mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
Modified: mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp Sun Aug 17 01:00:05 2014
@@ -60,15 +60,9 @@
// Remove this node and insert treeOne and treeTwo.
TreeType* par = tree->Parent();
- int index = 0;
- for (int i = 0; i < par->NumChildren(); i++)
- {
- if (par->Children()[i] == tree)
- {
- index = i;
- break;
- }
- }
+ size_t index = 0;
+ while (par->Children()[index] != tree) { ++index; }
+
par->Children()[index] = treeOne;
par->Children()[par->NumChildren()++] = treeTwo;
@@ -130,15 +124,9 @@
// Remove this node and insert treeOne and treeTwo.
TreeType* par = tree->Parent();
- int index = -1;
- for (int i = 0; i < par->NumChildren(); i++)
- {
- if (par->Children()[i] == tree)
- {
- index = i;
- break;
- }
- }
+ size_t index = 0;
+ while (par->Children()[index] != tree) { ++index; }
+
assert(index != -1);
par->Children()[index] = treeOne;
par->Children()[par->NumChildren()++] = treeTwo;
More information about the mlpack-svn
mailing list