[mlpack-git] [mlpack/mlpack] Remove code redundancy in ns_model_impl.hpp (#674)
sumedhghaisas
notifications at github.com
Fri Jun 3 16:27:42 EDT 2016
There are many similar code constructs are found in this file
For example...
`
if (kdTreeNS)
delete kdTreeNS;
if (coverTreeNS)
delete coverTreeNS;
if (rTreeNS)
delete rTreeNS;
if (rStarTreeNS)
delete rStarTreeNS;
if (ballTreeNS)
delete ballTreeNS;
if (xTreeNS)
delete xTreeNS;
`
is similar to ...
`
if (kdTreeNS)
return kdTreeNS->ReferenceSet();
else if (coverTreeNS)
return coverTreeNS->ReferenceSet();
else if (rTreeNS)
return rTreeNS->ReferenceSet();
else if (rStarTreeNS)
return rStarTreeNS->ReferenceSet();
else if (ballTreeNS)
return ballTreeNS->ReferenceSet();
else if (xTreeNS)
return xTreeNS->ReferenceSet();
`
I think it would be better to implement this using inheritance as we are doing the exact same thing that a compiler does but just with if-else clauses. (strictly having faith in people who optimizes compilers.). We can create an interface which is inherited by NSType templatized class and implement a getAppropriateTreePointer() which an interface pointer. (we should find better names).
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/674
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160603/8de827da/attachment.html>
More information about the mlpack-git
mailing list