<p>In <a href="https://github.com/mlpack/mlpack/pull/732#discussion_r71901732">src/mlpack/methods/cf/cf.hpp</a>:</p>
<pre style='color:#555'>> + {
> + //! Value of this recommendation.
> + double value;
> + //! Item of this recommendation.
> + size_t item;
> + //! Trivial constructor.
> + Candidate(double value, size_t item) :
> + value(value),
> + item(item)
> + {};
> + //! Compare the value of two candidates.
> + friend bool operator>(const Candidate& l, const Candidate& r)
> + {
> + return l.value > r.value;
> + };
> + };
</pre>
<p>Yep, your concerns are 100% valid. Take a look at <a href="https://github.com/mlpack/mlpack/issues/712" class="issue-link js-issue-link" data-url="https://github.com/mlpack/mlpack/issues/712" data-id="163035605" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#712</a> where <a href="https://github.com/lozhnikov" class="user-mention">@lozhnikov</a> and I researched different solutions to this same problem. <code>std::priority_queue</code> has a third template parameter---<code>Compare</code>---which you could use to specify either a lambda or a custom function for comparison, which would only compare the first element in the pair.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<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/files/57dd61f1d823f209c8d0f67fa69f8a8ae0669d18#r71901732">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFPE1uuepwYhY3CvwQTErTRyuHe9Xks5qYOfPgaJpZM4JScnZ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFGdya48bPwy6FdUCxpJydBKOoIIGks5qYOfPgaJpZM4JScnZ.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/files/57dd61f1d823f209c8d0f67fa69f8a8ae0669d18#r71901732"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>