<p>Great to hear that it's faster for k=1, too.</p>

<p>It's funny, this is kind of things coming full circle... a very long time ago, the NeighborSearch code (or AllkNN as the class was called) used to use <code>std::pair&lt;&gt;</code> to represent candidates:</p>

<p><a href="https://github.com/mlpack/mlpack/blob/43ac2c8a0f165aecb91ef5a5e8f9e0e7e0b3bb55/fastlib/trunk/mlpack/allknn/allknn.h#L375">https://github.com/mlpack/mlpack/blob/43ac2c8a0f165aecb91ef5a5e8f9e0e7e0b3bb55/fastlib/trunk/mlpack/allknn/allknn.h#L375</a><br>
(it's crazy how different the code was then... I forget how far things have come.  It's fun to browse around that repository and contrast with now)</p>

<p>But it used <code>std::vector&lt;std::pair&lt;&gt;&gt;</code> and then used <code>std::sort()</code> to sort them and remove the last element, instead of the much more reasonable priority queue.  When I replaced that (back in 2011 sometime) with individual vectors for the neighbors and distances, I achieved an order-of-magnitude speedup or more, especially for large k.  Now we are back to using <code>std::pair&lt;&gt;</code> (or similar), but this time with the right data structure---a heap. :)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/732#issuecomment-234610062">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFD-XPAYoDcelKzzst3Wjmd121kGxks5qYQJ4gaJpZM4JScnZ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFAwgUVtE4BMNW8ppO8kUAPxBwZr8ks5qYQJ4gaJpZM4JScnZ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/732#issuecomment-234610062"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>