[mlpack-git] master: Switch int to size_t in order to fix a very large number of warnings. (0dfe447)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:00:07 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

commit 0dfe44704a401cd378c00493c46b1f6de05e4266
Author: Ryan Curtin <ryan at ratml.org>
Date:   Thu Sep 11 21:10:55 2014 +0000

    Switch int to size_t in order to fix a very large number of warnings.


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

0dfe44704a401cd378c00493c46b1f6de05e4266
 .../rectangle_tree/dual_tree_traverser_impl.hpp    |  10 +-
 .../r_star_tree_descent_heuristic_impl.hpp         |   4 +-
 .../tree/rectangle_tree/r_star_tree_split_impl.hpp |  68 +++++++-------
 .../core/tree/rectangle_tree/r_tree_split_impl.hpp |  48 +++++-----
 .../tree/rectangle_tree/rectangle_tree_impl.hpp    |  10 +-
 .../rectangle_tree/single_tree_traverser_impl.hpp  |   4 +-
 .../core/tree/rectangle_tree/x_tree_split_impl.hpp | 103 ++++++++++-----------
 7 files changed, 123 insertions(+), 124 deletions(-)

diff --git a/src/mlpack/core/tree/rectangle_tree/dual_tree_traverser_impl.hpp b/src/mlpack/core/tree/rectangle_tree/dual_tree_traverser_impl.hpp
index 7214986..1c4bbf3 100644
--- a/src/mlpack/core/tree/rectangle_tree/dual_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/dual_tree_traverser_impl.hpp
@@ -93,7 +93,7 @@ DualTreeTraverser<RuleType>::Traverse(
 
     // We sort the children of the reference node by their scores.
     std::vector<NodeAndScore> nodesAndScores(referenceNode.NumChildren());
-    for(int i = 0; i < referenceNode.NumChildren(); i++)
+    for (size_t i = 0; i < referenceNode.NumChildren(); i++)
     {
       rule.TraversalInfo() = traversalInfo;
       nodesAndScores[i].node = referenceNode.Children()[i];
@@ -103,7 +103,7 @@ DualTreeTraverser<RuleType>::Traverse(
     std::sort(nodesAndScores.begin(), nodesAndScores.end(), nodeComparator);
     numScores += nodesAndScores.size();
 
-    for(int i = 0; i < nodesAndScores.size(); i++)
+    for (size_t i = 0; i < nodesAndScores.size(); i++)
     {
       rule.TraversalInfo() = nodesAndScores[i].travInfo;
       if(rule.Rescore(queryNode, *(nodesAndScores[i].node), nodesAndScores[i].score) < DBL_MAX) {
@@ -120,11 +120,11 @@ DualTreeTraverser<RuleType>::Traverse(
     // We loop through all of the query nodes, and for each of them, we
     // loop through the reference nodes to see where we need to descend.
 
-    for(int j = 0; j < queryNode.NumChildren(); j++)
+    for (size_t j = 0; j < queryNode.NumChildren(); j++)
     {
       // We sort the children of the reference node by their scores.
       std::vector<NodeAndScore> nodesAndScores(referenceNode.NumChildren());
-      for(int i = 0; i < referenceNode.NumChildren(); i++)
+      for (size_t i = 0; i < referenceNode.NumChildren(); i++)
       {
         rule.TraversalInfo() = traversalInfo;
         nodesAndScores[i].node = referenceNode.Children()[i];
@@ -134,7 +134,7 @@ DualTreeTraverser<RuleType>::Traverse(
       std::sort(nodesAndScores.begin(), nodesAndScores.end(), nodeComparator);
       numScores += nodesAndScores.size();
 
-      for(int i = 0; i < nodesAndScores.size(); i++)
+      for (size_t i = 0; i < nodesAndScores.size(); i++)
       {
         rule.TraversalInfo() = nodesAndScores[i].travInfo;
         if(rule.Rescore(queryNode.Child(j), *(nodesAndScores[i].node), nodesAndScores[i].score) < DBL_MAX) {
diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp
index e7f8bc8..e8800ea 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_descent_heuristic_impl.hpp
@@ -113,7 +113,7 @@ inline size_t RStarTreeDescentHeuristic::ChooseDescentNode(
     // We break ties by choosing the smallest bound.
     double minVol = DBL_MAX;
     bestIndex = 0;
-    for (int i = 0; i < scores.size(); i++)
+    for (size_t i = 0; i < scores.size(); i++)
     {
       if (scores[i] == minScore)
       {
@@ -178,7 +178,7 @@ inline size_t RStarTreeDescentHeuristic::ChooseDescentNode(
     // We break ties by choosing the smallest bound.
     double minVol = DBL_MAX;
     bestIndex = 0;
-    for (int i = 0; i < scores.size(); i++)
+    for (size_t i = 0; i < scores.size(); i++)
     {
       if (scores[i] == minScore)
       {
diff --git a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
index d1b5c20..2d771c0 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_star_tree_split_impl.hpp
@@ -98,12 +98,12 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   int bestAxis = 0;
   double bestAxisScore = DBL_MAX;
 
-  for (int j = 0; j < tree->Bound().Dim(); j++)
+  for (size_t j = 0; j < tree->Bound().Dim(); j++)
   {
     double axisScore = 0.0;
     // Since we only have points in the leaf nodes, we only need to sort once.
     std::vector<SortStruct> sorted(tree->Count());
-    for (int i = 0; i < sorted.size(); i++)
+    for (size_t i = 0; i < sorted.size(); i++)
     {
       sorted[i].d = tree->LocalDataset().col(i)[j];
       sorted[i].n = i;
@@ -119,14 +119,14 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
     std::vector<double> overlapedAreas(tree->MaxLeafSize() -
         2 * tree->MinLeafSize() + 2);
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       // The ith arrangement is obtained by placing the first
       // tree->MinLeafSize() + i points in one rectangle and the rest in
@@ -139,13 +139,13 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
       std::vector<double> minG1(maxG1.size());
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
-      for (int k = 0; k < tree->Bound().Dim(); k++)
+      for (size_t k = 0; k < tree->Bound().Dim(); k++)
       {
         minG1[k] = maxG1[k] = tree->LocalDataset().col(sorted[0].n)[k];
         minG2[k] = maxG2[k] =
             tree->LocalDataset().col(sorted[sorted.size() - 1].n)[k];
 
-        for (int l = 1; l < tree->Count() - 1; l++)
+        for (size_t l = 1; l < tree->Count() - 1; l++)
         {
           if (l < cutOff)
           {
@@ -166,7 +166,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
 
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
-      for (int k = 0; k < maxG1.size(); k++)
+      for (size_t k = 0; k < maxG1.size(); k++)
       {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
@@ -187,7 +187,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
       bestOverlapIndexOnBestAxis = 0;
       bestAreaIndexOnBestAxis = 0;
 
-      for (int i = 1; i < areas.size(); i++)
+      for (size_t i = 1; i < areas.size(); i++)
       {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis])
         {
@@ -207,7 +207,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   }
 
   std::vector<SortStruct> sorted(tree->Count());
-  for (int i = 0; i < sorted.size(); i++)
+  for (size_t i = 0; i < sorted.size(); i++)
   {
     sorted[i].d = tree->LocalDataset().col(i)[bestAxis];
     sorted[i].n = i;
@@ -220,7 +220,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
 
   if (tiedOnOverlap)
   {
-    for (int i = 0; i < tree->Count(); i++)
+    for (size_t i = 0; i < tree->Count(); i++)
     {
       if (i < bestAreaIndexOnBestAxis + tree->MinLeafSize())
         treeOne->InsertPoint(tree->Points()[sorted[i].n]);
@@ -230,7 +230,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   }
   else
   {
-    for (int i = 0; i < tree->Count(); i++)
+    for (size_t i = 0; i < tree->Count(); i++)
     {
       if (i < bestOverlapIndexOnBestAxis + tree->MinLeafSize())
         treeOne->InsertPoint(tree->Points()[sorted[i].n]);
@@ -244,7 +244,7 @@ void RStarTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   size_t index = 0;
   while (par->Children()[index] != tree) { index++; }
 
-  assert(index != -1);
+  assert(index != par->NumChildren());
   par->Children()[index] = treeOne;
   par->Children()[par->NumChildren()++] = treeTwo;
 
@@ -361,13 +361,13 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   bool lowIsBest = true;
   int bestAxis = 0;
   double bestAxisScore = DBL_MAX;
-  for (int j = 0; j < tree->Bound().Dim(); j++)
+  for (size_t j = 0; j < tree->Bound().Dim(); j++)
   {
     double axisScore = 0.0;
 
     // We'll do Bound().Lo() now and use Bound().Hi() later.
     std::vector<SortStruct> sorted(tree->NumChildren());
-    for (int i = 0; i < sorted.size(); i++)
+    for (size_t i = 0; i < sorted.size(); i++)
     {
       sorted[i].d = tree->Children()[i]->Bound()[j].Lo();
       sorted[i].n = i;
@@ -383,14 +383,14 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     std::vector<double> overlapedAreas(tree->MaxNumChildren() -
         2 * tree->MinNumChildren() + 2);
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       // The ith arrangement is obtained by placing the first
       // tree->MinNumChildren() + i points in one rectangle and the rest in
@@ -403,7 +403,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       std::vector<double> minG1(maxG1.size());
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
-      for (int k = 0; k < tree->Bound().Dim(); k++)
+      for (size_t k = 0; k < tree->Bound().Dim(); k++)
       {
         minG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Lo();
         maxG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Hi();
@@ -412,7 +412,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
         maxG2[k] =
             tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Hi();
 
-        for (int l = 1; l < tree->NumChildren() - 1; l++)
+        for (size_t l = 1; l < tree->NumChildren() - 1; l++)
         {
           if (l < cutOff)
           {
@@ -433,7 +433,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
-      for (int k = 0; k < maxG1.size(); k++)
+      for (size_t k = 0; k < maxG1.size(); k++)
       {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
@@ -453,7 +453,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       bestAxis = j;
       double bestOverlapIndexOnBestAxis = 0;
       double bestAreaIndexOnBestAxis = 0;
-      for (int i = 1; i < areas.size(); i++)
+      for (size_t i = 1; i < areas.size(); i++)
       {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis])
         {
@@ -473,13 +473,13 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   }
 
   // Now we do the same thing using Bound().Hi() and choose the best of the two.
-  for (int j = 0; j < tree->Bound().Dim(); j++)
+  for (size_t j = 0; j < tree->Bound().Dim(); j++)
   {
     double axisScore = 0.0;
 
     // We'll do Bound().Lo() now and use Bound().Hi() later.
     std::vector<SortStruct> sorted(tree->NumChildren());
-    for (int i = 0; i < sorted.size(); i++)
+    for (size_t i = 0; i < sorted.size(); i++)
     {
       sorted[i].d = tree->Children()[i]->Bound()[j].Hi();
       sorted[i].n = i;
@@ -495,14 +495,14 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     std::vector<double> overlapedAreas(tree->MaxNumChildren() -
         2 * tree->MinNumChildren() + 2);
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
 
-    for (int i = 0; i < areas.size(); i++)
+    for (size_t i = 0; i < areas.size(); i++)
     {
       // The ith arrangement is obtained by placing the first
       // tree->MinNumChildren() + i points in one rectangle and the rest in
@@ -516,7 +516,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
 
-      for (int k = 0; k < tree->Bound().Dim(); k++)
+      for (size_t k = 0; k < tree->Bound().Dim(); k++)
       {
         minG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Lo();
         maxG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Hi();
@@ -525,7 +525,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
         maxG2[k] =
             tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Hi();
 
-        for (int l = 1; l < tree->NumChildren() - 1; l++)
+        for (size_t l = 1; l < tree->NumChildren() - 1; l++)
         {
           if (l < cutOff)
           {
@@ -547,7 +547,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
 
-      for (int k = 0; k < maxG1.size(); k++)
+      for (size_t k = 0; k < maxG1.size(); k++)
       {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
@@ -569,7 +569,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       double bestOverlapIndexOnBestAxis = 0;
       double bestAreaIndexOnBestAxis = 0;
 
-      for (int i = 1; i < areas.size(); i++)
+      for (size_t i = 1; i < areas.size(); i++)
       {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis])
         {
@@ -591,7 +591,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   std::vector<SortStruct> sorted(tree->NumChildren());
   if (lowIsBest)
   {
-    for (int i = 0; i < sorted.size(); i++)
+    for (size_t i = 0; i < sorted.size(); i++)
     {
       sorted[i].d = tree->Children()[i]->Bound()[bestAxis].Lo();
       sorted[i].n = i;
@@ -599,7 +599,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   }
   else
   {
-    for (int i = 0; i < sorted.size(); i++)
+    for (size_t i = 0; i < sorted.size(); i++)
     {
       sorted[i].d = tree->Children()[i]->Bound()[bestAxis].Hi();
       sorted[i].n = i;
@@ -613,7 +613,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   if (tiedOnOverlap)
   {
-    for (int i = 0; i < tree->NumChildren(); i++)
+    for (size_t i = 0; i < tree->NumChildren(); i++)
     {
       if (i < bestAreaIndexOnBestAxis + tree->MinNumChildren())
         InsertNodeIntoTree(treeOne, tree->Children()[sorted[i].n]);
@@ -623,7 +623,7 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   }
   else
   {
-    for (int i = 0; i < tree->NumChildren(); i++)
+    for (size_t i = 0; i < tree->NumChildren(); i++)
     {
       if (i < bestOverlapIndexOnBestAxis + tree->MinNumChildren())
         InsertNodeIntoTree(treeOne, tree->Children()[sorted[i].n]);
@@ -650,10 +650,10 @@ bool RStarTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   // We have to update the children of each of these new nodes so that they
   // record the correct parent.
-  for (int i = 0; i < treeOne->NumChildren(); i++)
+  for (size_t i = 0; i < treeOne->NumChildren(); i++)
     treeOne->Children()[i]->Parent() = treeOne;
 
-  for (int i = 0; i < treeTwo->NumChildren(); i++)
+  for (size_t i = 0; i < treeTwo->NumChildren(); i++)
     treeTwo->Children()[i]->Parent() = treeTwo;
 
   assert(treeOne->Parent()->NumChildren() <= treeOne->MaxNumChildren());
diff --git a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
index 1905a91..22aa7a1 100644
--- a/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/r_tree_split_impl.hpp
@@ -127,11 +127,11 @@ bool RTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   size_t index = 0;
   while (par->Children()[index] != tree) { ++index; }
 
-  assert(index != -1);
+  assert(index != par->NumChildren());
   par->Children()[index] = treeOne;
   par->Children()[par->NumChildren()++] = treeTwo;
 
-  for (int i = 0; i < par->NumChildren(); i++)
+  for (size_t i = 0; i < par->NumChildren(); i++)
     assert(par->Children()[i] != tree);
 
   // We only add one at a time, so should only need to test for equality just in
@@ -143,10 +143,10 @@ bool RTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   // We have to update the children of each of these new nodes so that they
   // record the correct parent.
-  for (int i = 0; i < treeOne->NumChildren(); i++)
+  for (size_t i = 0; i < treeOne->NumChildren(); i++)
     treeOne->Children()[i]->Parent() = treeOne;
 
-  for (int i = 0; i < treeTwo->NumChildren(); i++)
+  for (size_t i = 0; i < treeTwo->NumChildren(); i++)
     treeTwo->Children()[i]->Parent() = treeTwo;
 
   assert(treeOne->NumChildren() <= treeOne->MaxNumChildren());
@@ -176,9 +176,9 @@ void RTreeSplit<DescentType, StatisticType, MatType>::GetPointSeeds(
   // same node.  Because we are just using points, we will simply choose the two
   // that would create the most voluminous hyperrectangle.
   double worstPairScore = -1.0;
-  for (int i = 0; i < tree.Count(); i++)
+  for (size_t i = 0; i < tree.Count(); i++)
   {
-    for (int j = i + 1; j < tree.Count(); j++)
+    for (size_t j = i + 1; j < tree.Count(); j++)
     {
       const double score = arma::prod(arma::abs(tree.LocalDataset().col(i) -
           tree.LocalDataset().col(j)));
@@ -206,12 +206,12 @@ void RTreeSplit<DescentType, StatisticType, MatType>::GetBoundSeeds(
     int& jRet)
 {
   double worstPairScore = -1.0;
-  for (int i = 0; i < tree.NumChildren(); i++)
+  for (size_t i = 0; i < tree.NumChildren(); i++)
   {
-    for (int j = i + 1; j < tree.NumChildren(); j++)
+    for (size_t j = i + 1; j < tree.NumChildren(); j++)
     {
       double score = 1.0;
-      for (int k = 0; k < tree.Bound().Dim(); k++)
+      for (size_t k = 0; k < tree.Bound().Dim(); k++)
       {
         const double hiMax = std::max(tree.Children()[i]->Bound()[k].Hi(),
                                       tree.Children()[j]->Bound()[k].Hi());
@@ -269,8 +269,8 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignPointDestNode(
     oldTree->LocalDataset().col(intI) = oldTree->LocalDataset().col(end);
   }
 
-  int numAssignedOne = 1;
-  int numAssignedTwo = 1;
+  size_t numAssignedOne = 1;
+  size_t numAssignedTwo = 1;
 
   // In each iteration, we go through all points and find the one that causes
   // the least increase of volume when added to one of the rectangles.  We then
@@ -302,11 +302,11 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignPointDestNode(
 
     // Find the point that, when assigned to one of the two new rectangles,
     // minimizes the increase in volume.
-    for (int index = 0; index < end; index++)
+    for (size_t index = 0; index < end; index++)
     {
       double newVolOne = 1.0;
       double newVolTwo = 1.0;
-      for (int i = 0; i < oldTree->Bound().Dim(); i++)
+      for (size_t i = 0; i < oldTree->Bound().Dim(); i++)
       {
         double c = oldTree->LocalDataset().col(index)[i];
         newVolOne *= treeOne->Bound()[i].Contains(c) ?
@@ -387,8 +387,8 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignNodeDestNode(
 
   assert(intI != intJ);
 
-  for (int i = 0; i < oldTree->NumChildren(); i++)
-    for (int j = i + 1; j < oldTree->NumChildren(); j++)
+  for (size_t i = 0; i < oldTree->NumChildren(); i++)
+    for (size_t j = i + 1; j < oldTree->NumChildren(); j++)
       assert(oldTree->Children()[i] != oldTree->Children()[j]);
 
   InsertNodeIntoTree(treeOne, oldTree->Children()[intI]);
@@ -420,8 +420,8 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignNodeDestNode(
   for (int i = 0; i < end; i++)
     assert(oldTree->Children()[i] != treeTwo->Children()[0]);
 
-  int numAssignTreeOne = 1;
-  int numAssignTreeTwo = 1;
+  size_t numAssignTreeOne = 1;
+  size_t numAssignTreeTwo = 1;
 
   // In each iteration, we go through all of the nodes and find the one that
   // causes the least increase of volume when added to one of the two new
@@ -437,17 +437,17 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignNodeDestNode(
     // new rectangles.
     double volOne = 1.0;
     double volTwo = 1.0;
-    for (int i = 0; i < oldTree->Bound().Dim(); i++)
+    for (size_t i = 0; i < oldTree->Bound().Dim(); i++)
     {
       volOne *= treeOne->Bound()[i].Width();
       volTwo *= treeTwo->Bound()[i].Width();
     }
 
-    for (int index = 0; index < end; index++)
+    for (size_t index = 0; index < end; index++)
     {
       double newVolOne = 1.0;
       double newVolTwo = 1.0;
-      for (int i = 0; i < oldTree->Bound().Dim(); i++)
+      for (size_t i = 0; i < oldTree->Bound().Dim(); i++)
       {
         // For each of the new rectangles, find the width in this dimension if
         // we add the rectangle at index to the new rectangle.
@@ -523,12 +523,12 @@ void RTreeSplit<DescentType, StatisticType, MatType>::AssignNodeDestNode(
     }
   }
 
-  for (int i = 0; i < treeOne->NumChildren(); i++)
-    for (int j = i + 1; j < treeOne->NumChildren(); j++)
+  for (size_t i = 0; i < treeOne->NumChildren(); i++)
+    for (size_t j = i + 1; j < treeOne->NumChildren(); j++)
       assert(treeOne->Children()[i] != treeOne->Children()[j]);
 
-  for (int i = 0; i < treeTwo->NumChildren(); i++)
-    for (int j = i + 1; j < treeTwo->NumChildren(); j++)
+  for (size_t i = 0; i < treeTwo->NumChildren(); i++)
+    for (size_t j = i + 1; j < treeTwo->NumChildren(); j++)
       assert(treeTwo->Children()[i] != treeTwo->Children()[j]);
 }
 
diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
index afbb5dc..01e24bd 100644
--- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp
@@ -139,7 +139,7 @@ template<typename SplitType,
          typename MatType>
 RectangleTree<SplitType, DescentType, StatisticType, MatType>::~RectangleTree()
 {
-  for (int i = 0; i < numChildren; i++)
+  for (size_t i = 0; i < numChildren; i++)
     delete children[i];
 
   delete localDataset;
@@ -157,7 +157,7 @@ void RectangleTree<SplitType, DescentType, StatisticType, MatType>::SoftDelete()
 {
   parent = NULL;
 
-  for (int i = 0; i < children.size(); i++)
+  for (size_t i = 0; i < children.size(); i++)
     children[i] = NULL;
 
   numChildren = 0;
@@ -192,7 +192,7 @@ void RectangleTree<SplitType, DescentType, StatisticType, MatType>::InsertPoint(
   bound |= dataset.col(point);
 
   std::vector<bool> lvls(TreeDepth());
-  for (int i = 0; i < lvls.size(); i++)
+  for (size_t i = 0; i < lvls.size(); i++)
     lvls[i] = true;
 
   // If this is a leaf node, we stop here and add the point.
@@ -294,7 +294,7 @@ bool RectangleTree<SplitType, DescentType, StatisticType, MatType>::DeletePoint(
     root = root->Parent();
 
   std::vector<bool> lvls(root->TreeDepth());
-  for (int i = 0; i < lvls.size(); i++)
+  for (size_t i = 0; i < lvls.size(); i++)
     lvls[i] = true;
 
   if (numChildren == 0)
@@ -502,7 +502,7 @@ inline size_t RectangleTree<SplitType, DescentType, StatisticType, MatType>::
   else
   {
     size_t n = 0;
-    for (int i = 0; i < numChildren; i++)
+    for (size_t i = 0; i < numChildren; i++)
       n += children[i]->NumDescendants();
 
     return n;
diff --git a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
index 2bae871..68f8f1f 100644
--- a/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/single_tree_traverser_impl.hpp
@@ -52,7 +52,7 @@ SingleTreeTraverser<RuleType>::Traverse(
   // This is not a leaf node so we sort the children of this node by their
   // scores.
   std::vector<NodeAndScore> nodesAndScores(referenceNode.NumChildren());
-  for (int i = 0; i < referenceNode.NumChildren(); i++)
+  for (size_t i = 0; i < referenceNode.NumChildren(); i++)
   {
     nodesAndScores[i].node = referenceNode.Children()[i];
     nodesAndScores[i].score = rule.Score(queryIndex, *nodesAndScores[i].node);
@@ -62,7 +62,7 @@ SingleTreeTraverser<RuleType>::Traverse(
 
   // Now iterate through them starting with the best and stopping when we reach
   // one that isn't good enough.
-  for (int i = 0; i < referenceNode.NumChildren(); i++)
+  for (size_t i = 0; i < referenceNode.NumChildren(); i++)
   {
     if (rule.Rescore(queryIndex, *nodesAndScores[i].node,
         nodesAndScores[i].score) != DBL_MAX)
diff --git a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
index f1530a2..5ab24ff 100644
--- a/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
+++ b/src/mlpack/core/tree/rectangle_tree/x_tree_split_impl.hpp
@@ -95,11 +95,11 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   bool tiedOnOverlap = false;
   int bestAxis = 0;
   double bestAxisScore = DBL_MAX;
-  for (int j = 0; j < tree->Bound().Dim(); j++) {
+  for (size_t j = 0; j < tree->Bound().Dim(); j++) {
     double axisScore = 0.0;
     // Since we only have points in the leaf nodes, we only need to sort once.
     std::vector<sortStruct> sorted(tree->Count());
-    for (int i = 0; i < sorted.size(); i++) {
+    for (size_t i = 0; i < sorted.size(); i++) {
       sorted[i].d = tree->LocalDataset().col(i)[j];
       sorted[i].n = i;
     }
@@ -110,26 +110,26 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
     std::vector<double> areas(tree->MaxLeafSize() - 2 * tree->MinLeafSize() + 2);
     std::vector<double> margins(tree->MaxLeafSize() - 2 * tree->MinLeafSize() + 2);
     std::vector<double> overlapedAreas(tree->MaxLeafSize() - 2 * tree->MinLeafSize() + 2);
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       // The ith arrangement is obtained by placing the first tree->MinLeafSize() + i
       // points in one rectangle and the rest in another.  Then we calculate the three
       // scores for that distribution.
 
-      int cutOff = tree->MinLeafSize() + i;
+      size_t cutOff = tree->MinLeafSize() + i;
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
       std::vector<double> minG1(maxG1.size());
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
-      for (int k = 0; k < tree->Bound().Dim(); k++) {
+      for (size_t k = 0; k < tree->Bound().Dim(); k++) {
         minG1[k] = maxG1[k] = tree->LocalDataset().col(sorted[0].n)[k];
         minG2[k] = maxG2[k] = tree->LocalDataset().col(sorted[sorted.size() - 1].n)[k];
-        for (int l = 1; l < tree->Count() - 1; l++) {
+        for (size_t l = 1; l < tree->Count() - 1; l++) {
           if (l < cutOff) {
             if (tree->LocalDataset().col(sorted[l].n)[k] < minG1[k])
               minG1[k] = tree->LocalDataset().col(sorted[l].n)[k];
@@ -145,7 +145,7 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
       }
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
-      for (int k = 0; k < maxG1.size(); k++) {
+      for (size_t k = 0; k < maxG1.size(); k++) {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
         area2 *= maxG2[k] - minG2[k];
@@ -161,7 +161,7 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
       bestAxis = j;
       bestOverlapIndexOnBestAxis = 0;
       bestAreaIndexOnBestAxis = 0;
-      for (int i = 1; i < areas.size(); i++) {
+      for (size_t i = 1; i < areas.size(); i++) {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis]) {
           tiedOnOverlap = false;
           bestAreaIndexOnBestAxis = i;
@@ -176,7 +176,7 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   }
 
   std::vector<sortStruct> sorted(tree->Count());
-  for (int i = 0; i < sorted.size(); i++) {
+  for (size_t i = 0; i < sorted.size(); i++) {
     sorted[i].d = tree->LocalDataset().col(i)[bestAxis];
     sorted[i].n = i;
   }
@@ -192,14 +192,14 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
   // since a split axis is chosen and then points are assigned based on their value
   // along that axis.
   if (tiedOnOverlap) {
-    for (int i = 0; i < tree->Count(); i++) {
+    for (size_t i = 0; i < tree->Count(); i++) {
       if (i < bestAreaIndexOnBestAxis + tree->MinLeafSize())
         treeOne->InsertPoint(tree->Points()[sorted[i].n]);
       else
         treeTwo->InsertPoint(tree->Points()[sorted[i].n]);
     }
   } else {
-    for (int i = 0; i < tree->Count(); i++) {
+    for (size_t i = 0; i < tree->Count(); i++) {
       if (i < bestOverlapIndexOnBestAxis + tree->MinLeafSize())
         treeOne->InsertPoint(tree->Points()[sorted[i].n]);
       else
@@ -209,14 +209,14 @@ void XTreeSplit<DescentType, StatisticType, MatType>::SplitLeafNode(
 
   //Remove this node and insert treeOne and treeTwo
   RectangleTree<XTreeSplit<DescentType, StatisticType, MatType>, DescentType, StatisticType, MatType>* par = tree->Parent();
-  int index = -1;
-  for (int i = 0; i < par->NumChildren(); i++) {
+  size_t index = par->NumChildren();
+  for (size_t i = 0; i < par->NumChildren(); i++) {
     if (par->Children()[i] == tree) {
       index = i;
       break;
     }
   }
-  assert(index != -1);
+  assert(index != par->NumChildren());
   par->Children()[index] = treeOne;
   par->Children()[par->NumChildren()++] = treeTwo;
 
@@ -285,8 +285,8 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     dimensionsLastUsed[i] = tree->Child(i).SplitHistory().lastDimension;
   std::sort(dimensionsLastUsed.begin(), dimensionsLastUsed.end());
 
-  int lastDim = dimensionsLastUsed[dimensionsLastUsed.size()/2];
-  int minOverlapSplitDimension = -1;
+  size_t lastDim = dimensionsLastUsed[dimensionsLastUsed.size()/2];
+  size_t minOverlapSplitDimension = tree->Bound().Dim();
 
   // See if we can use a new dimension.
   for(size_t i = lastDim + 1; i < axes.size(); i++) {
@@ -298,8 +298,8 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       break;
     }
   }
-  if(minOverlapSplitDimension == -1) {
-    for(size_t i = 0; i < lastDim + 1; i++) {
+  if (minOverlapSplitDimension == tree->Bound().Dim()) {
+    for (size_t i = 0; i < lastDim + 1; i++) {
       axes[i] = true;
       for(size_t j = 0; j < tree->NumChildren(); j++)
         axes[i] = axes[i] & tree->Child(j).SplitHistory().history[i];
@@ -327,12 +327,12 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   double overlapBestAreaAxis = 0;
   double areaBestAreaAxis = 0;
 
-  for (int j = 0; j < tree->Bound().Dim(); j++) {
+  for (size_t j = 0; j < tree->Bound().Dim(); j++) {
     double axisScore = 0.0;
 
     // We'll do Bound().Lo() now and use Bound().Hi() later.
     std::vector<sortStruct> sorted(tree->NumChildren());
-    for (int i = 0; i < sorted.size(); i++) {
+    for (size_t i = 0; i < sorted.size(); i++) {
       sorted[i].d = tree->Children()[i]->Bound()[j].Lo();
       sorted[i].n = i;
     }
@@ -343,29 +343,29 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     std::vector<double> areas(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
     std::vector<double> margins(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
     std::vector<double> overlapedAreas(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
 
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       // The ith arrangement is obtained by placing the first tree->MinNumChildren() + i
       // points in one rectangle and the rest in another.  Then we calculate the three
       // scores for that distribution.
 
-      int cutOff = tree->MinNumChildren() + i;
+      size_t cutOff = tree->MinNumChildren() + i;
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
       std::vector<double> minG1(maxG1.size());
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
-      for (int k = 0; k < tree->Bound().Dim(); k++) {
+      for (size_t k = 0; k < tree->Bound().Dim(); k++) {
         minG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Lo();
         maxG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Hi();
         minG2[k] = tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Lo();
         maxG2[k] = tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Hi();
-        for (int l = 1; l < tree->NumChildren() - 1; l++) {
+        for (size_t l = 1; l < tree->NumChildren() - 1; l++) {
           if (l < cutOff) {
             if (tree->Children()[sorted[l].n]->Bound()[k].Lo() < minG1[k])
               minG1[k] = tree->Children()[sorted[l].n]->Bound()[k].Lo();
@@ -381,7 +381,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       }
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
-      for (int k = 0; k < maxG1.size(); k++) {
+      for (size_t k = 0; k < maxG1.size(); k++) {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
         area2 *= maxG2[k] - minG2[k];
@@ -396,7 +396,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       bestAxis = j;
       double bestOverlapIndexOnBestAxis = 0;
       double bestAreaIndexOnBestAxis = 0;
-      for (int i = 1; i < areas.size(); i++) {
+      for (size_t i = 1; i < areas.size(); i++) {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis]) {
           tiedOnOverlap = false;
           bestAreaIndexOnBestAxis = i;
@@ -416,7 +416,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
     // Track the minOverlapSplit data
     if(minOverlapSplitDimension != -1 && j == minOverlapSplitDimension) {
-      for(int i = 0; i < overlapedAreas.size(); i++) {
+      for(size_t i = 0; i < overlapedAreas.size(); i++) {
         if(overlapedAreas[i] < bestScoreMinOverlapSplit) {
           bestScoreMinOverlapSplit = overlapedAreas[i];
           bestIndexMinOverlapSplit = i;
@@ -427,12 +427,12 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   }
 
   //Now we do the same thing using Bound().Hi() and choose the best of the two.
-  for (int j = 0; j < tree->Bound().Dim(); j++) {
+  for (size_t j = 0; j < tree->Bound().Dim(); j++) {
     double axisScore = 0.0;
 
     // We'll do Bound().Lo() now and use Bound().Hi() later.
     std::vector<sortStruct> sorted(tree->NumChildren());
-    for (int i = 0; i < sorted.size(); i++) {
+    for (size_t i = 0; i < sorted.size(); i++) {
       sorted[i].d = tree->Children()[i]->Bound()[j].Hi();
       sorted[i].n = i;
     }
@@ -443,29 +443,29 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     std::vector<double> areas(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
     std::vector<double> margins(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
     std::vector<double> overlapedAreas(tree->MaxNumChildren() - 2 * tree->MinNumChildren() + 2);
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       areas[i] = 0.0;
       margins[i] = 0.0;
       overlapedAreas[i] = 0.0;
     }
 
-    for (int i = 0; i < areas.size(); i++) {
+    for (size_t i = 0; i < areas.size(); i++) {
       // The ith arrangement is obtained by placing the first tree->MinNumChildren() + i
       // points in one rectangle and the rest in another.  Then we calculate the three
       // scores for that distribution.
 
-      int cutOff = tree->MinNumChildren() + i;
+      size_t cutOff = tree->MinNumChildren() + i;
       // We'll calculate the max and min in each dimension by hand to save time.
       std::vector<double> maxG1(tree->Bound().Dim());
       std::vector<double> minG1(maxG1.size());
       std::vector<double> maxG2(maxG1.size());
       std::vector<double> minG2(maxG1.size());
-      for (int k = 0; k < tree->Bound().Dim(); k++) {
+      for (size_t k = 0; k < tree->Bound().Dim(); k++) {
         minG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Lo();
         maxG1[k] = tree->Children()[sorted[0].n]->Bound()[k].Hi();
         minG2[k] = tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Lo();
         maxG2[k] = tree->Children()[sorted[sorted.size() - 1].n]->Bound()[k].Hi();
-        for (int l = 1; l < tree->NumChildren() - 1; l++) {
+        for (size_t l = 1; l < tree->NumChildren() - 1; l++) {
           if (l < cutOff) {
             if (tree->Children()[sorted[l].n]->Bound()[k].Lo() < minG1[k])
               minG1[k] = tree->Children()[sorted[l].n]->Bound()[k].Lo();
@@ -481,7 +481,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       }
       double area1 = 1.0, area2 = 1.0;
       double oArea = 1.0;
-      for (int k = 0; k < maxG1.size(); k++) {
+      for (size_t k = 0; k < maxG1.size(); k++) {
         margins[i] += maxG1[k] - minG1[k] + maxG2[k] - minG2[k];
         area1 *= maxG1[k] - minG1[k];
         area2 *= maxG2[k] - minG2[k];
@@ -497,7 +497,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       lowIsBest = false;
       double bestOverlapIndexOnBestAxis = 0;
       double bestAreaIndexOnBestAxis = 0;
-      for (int i = 1; i < areas.size(); i++) {
+      for (size_t i = 1; i < areas.size(); i++) {
         if (overlapedAreas[i] < overlapedAreas[bestOverlapIndexOnBestAxis]) {
           tiedOnOverlap = false;
           bestAreaIndexOnBestAxis = i;
@@ -517,7 +517,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
     // Track the minOverlapSplit data
     if(minOverlapSplitDimension != -1 && j == minOverlapSplitDimension) {
-      for(int i = 0; i < overlapedAreas.size(); i++) {
+      for(size_t i = 0; i < overlapedAreas.size(); i++) {
         if(overlapedAreas[i] < bestScoreMinOverlapSplit) {
           minOverlapSplitUsesHi = true;
           bestScoreMinOverlapSplit = overlapedAreas[i];
@@ -530,12 +530,12 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   std::vector<sortStruct> sorted(tree->NumChildren());
   if (lowIsBest) {
-    for (int i = 0; i < sorted.size(); i++) {
+    for (size_t i = 0; i < sorted.size(); i++) {
       sorted[i].d = tree->Children()[i]->Bound()[bestAxis].Lo();
       sorted[i].n = i;
     }
   } else {
-    for (int i = 0; i < sorted.size(); i++) {
+    for (size_t i = 0; i < sorted.size(); i++) {
       sorted[i].d = tree->Children()[i]->Bound()[bestAxis].Hi();
       sorted[i].n = i;
     }
@@ -552,7 +552,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
   bool useMinOverlapSplit = false;
   if (tiedOnOverlap) {
     if(overlapBestAreaAxis/areaBestAreaAxis < MAX_OVERLAP) {
-      for (int i = 0; i < tree->NumChildren(); i++) {
+      for (size_t i = 0; i < tree->NumChildren(); i++) {
         if (i < bestAreaIndexOnBestAxis + tree->MinNumChildren())
           InsertNodeIntoTree(treeOne, tree->Children()[sorted[i].n]);
         else
@@ -562,7 +562,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       useMinOverlapSplit = true;
   } else {
     if(overlapBestOverlapAxis/areaBestOverlapAxis < MAX_OVERLAP) {
-      for (int i = 0; i < tree->NumChildren(); i++) {
+      for (size_t i = 0; i < tree->NumChildren(); i++) {
         if (i < bestOverlapIndexOnBestAxis + tree->MinNumChildren())
           InsertNodeIntoTree(treeOne, tree->Children()[sorted[i].n]);
         else
@@ -579,7 +579,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
     if(minOverlapSplitDimension != -1 && bestScoreMinOverlapSplit / areaOfBestMinOverlapSplit < MAX_OVERLAP) {
       std::vector<sortStruct> sorted2(tree->NumChildren());
       if (minOverlapSplitUsesHi) {
-        for (int i = 0; i < sorted2.size(); i++) {
+        for (size_t i = 0; i < sorted2.size(); i++) {
           sorted2[i].d = tree->Children()[i]->Bound()[bestAxis].Hi();
           sorted2[i].n = i;
         }
@@ -590,7 +590,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
         }
       }
       std::sort(sorted2.begin(), sorted2.end(), structComp);
-      for (int i = 0; i < tree->NumChildren(); i++) {
+      for (size_t i = 0; i < tree->NumChildren(); i++) {
         if (i < bestIndexMinOverlapSplit + tree->MinNumChildren())
           InsertNodeIntoTree(treeOne, tree->Children()[sorted[i].n]);
         else
@@ -614,7 +614,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
         tree->Parent()->MaxNumChildren() *= 2;
         tree->Parent()->Children().resize(tree->Parent()->MaxNumChildren()+1);
         tree->Parent()->NumChildren() = tree->NumChildren();
-        for(int i = 0; i < tree->NumChildren(); i++) {
+        for(size_t i = 0; i < tree->NumChildren(); i++) {
           tree->Parent()->Children()[i] = tree->Children()[i];
         }
         delete treeOne;
@@ -629,7 +629,7 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
       // If we don't have to worry about the root, we just enlarge this node.
       tree->MaxNumChildren() *= 2;
       tree->Children().resize(tree->MaxNumChildren()+1);
-      for(int i = 0; i < tree->NumChildren(); i++)
+      for(size_t i = 0; i < tree->NumChildren(); i++)
         tree->Child(i).Parent() = tree;
       delete treeOne;
       delete treeTwo;
@@ -654,8 +654,8 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   //Remove this node and insert treeOne and treeTwo
   RectangleTree<XTreeSplit<DescentType, StatisticType, MatType>, DescentType, StatisticType, MatType>* par = tree->Parent();
-  int index = 0;
-  for (int i = 0; i < par->NumChildren(); i++) {
+  size_t index = 0;
+  for (size_t i = 0; i < par->NumChildren(); i++) {
     if (par->Children()[i] == tree) {
       index = i;
       break;
@@ -677,14 +677,13 @@ bool XTreeSplit<DescentType, StatisticType, MatType>::SplitNonLeafNode(
 
   // We have to update the children of each of these new nodes so that they record the
   // correct parent.
-  for (int i = 0; i < treeOne->NumChildren(); i++) {
+  for (size_t i = 0; i < treeOne->NumChildren(); i++) {
     treeOne->Children()[i]->Parent() = treeOne;
   }
-  for (int i = 0; i < treeTwo->NumChildren(); i++) {
+  for (size_t i = 0; i < treeTwo->NumChildren(); i++) {
     treeTwo->Children()[i]->Parent() = treeTwo;
   }
 
-  
   assert(treeOne->Parent()->NumChildren() <= treeOne->Parent()->MaxNumChildren());
   assert(treeOne->Parent()->NumChildren() >= treeOne->Parent()->MinNumChildren());
   assert(treeTwo->Parent()->NumChildren() <= treeTwo->Parent()->MaxNumChildren());



More information about the mlpack-git mailing list