[mlpack] 79/207: Add untested implementation for move and copy constructors.
Barak A. Pearlmutter
barak+git at pearlmutter.net
Thu Mar 23 17:53:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
bap pushed a commit to branch master
in repository mlpack.
commit 233d8324e50fcb603ba9d67c065534467c9a8ae9
Author: Ryan Curtin <ryan at ratml.org>
Date: Wed Aug 10 16:11:16 2016 -0400
Add untested implementation for move and copy constructors.
---
.../neighbor_search/neighbor_search_impl.hpp | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp
index 8aea761..c4ec410 100644
--- a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp
+++ b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp
@@ -391,6 +391,64 @@ SingleTreeTraversalType>::NeighborSearch(const bool naive,
}
}
+// Copy constructor.
+template<typename SortPolicy,
+ typename MetricType,
+ typename MatType,
+ template<typename TreeMetricType,
+ typename TreeStatType,
+ typename TreeMatType> class TreeType,
+ template<typename> class TraversalType>
+NeighborSearch<SortPolicy, MetricType, MatType, TreeType, TraversalType>::
+NeighborSearch(const NeighborSearch& other) :
+ oldFromNewReferences(other.oldFromNewReferences),
+ referenceTree(other.naive ? NULL : new Tree(*other.referenceTree)),
+ referenceSet(other.naive ? new MatType(*other.referenceSet) :
+ &referenceTree->Dataset()),
+ treeOwner(!other.naive),
+ setOwner(other.naive),
+ naive(other.naive),
+ singleMode(other.singleMode),
+ epsilon(other.epsilon),
+ metric(other.metric),
+ baseCases(other.baseCases),
+ scores(other.scores),
+ treeNeedsReset(other.treeNeedsReset)
+{
+ // Nothing to do.
+}
+
+// Move constructor.
+template<typename SortPolicy,
+ typename MetricType,
+ typename MatType,
+ template<typename TreeMetricType,
+ typename TreeStatType,
+ typename TreeMatType> class TreeType,
+ template<typename> class TraversalType>
+NeighborSearch<SortPolicy, MetricType, MatType, TreeType, TraversalType>::
+NeighborSearch(NeighborSearch&& other) :
+ oldFromNewReferences(std::move(other.oldFromNewReferences)),
+ referenceTree(other.referenceTree),
+ referenceSet(other.referenceSet),
+ treeOwner(other.treeOwner),
+ setOwner(other.setOwner),
+ naive(other.naive),
+ singleMode(other.singleMode),
+ epsilon(other.epsilon),
+ metric(std::move(other.metric)),
+ baseCases(other.baseCases),
+ scores(other.scores),
+ treeNeedsReset(other.treeNeedsReset)
+{
+ other.referenceTree = NULL;
+ other.referenceSet = new arma::mat(); // Empty dataset.
+ other.treeOwner = false;
+ other.setOwner = true;
+ other.baseCases = 0;
+ other.scores = 0;
+}
+
// Clean memory.
template<typename SortPolicy,
typename MetricType,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git
More information about the debian-science-commits
mailing list