[mlpack-git] [mlpack/mlpack] Heaps for mlpack! (#732)

Ryan Curtin notifications at github.com
Tue Jul 26 14:14:05 EDT 2016


> +  //! Candidate represents a possible candidate point (value, index).
> +  typedef std::pair<double, size_t> Candidate;
> +
> +  //! Compare two candidates based on the value.
> +  struct CandidateCmp {
> +    bool operator()(const Candidate& c1, const Candidate& c2)
> +    {
> +      return c1.first > c2.first;
> +    };
> +  };
> +
> +  //! Use a min heap to represent the list of candidate points.
> +  //! We will use a vector and the std functions: push_heap() pop_heap().
> +  //! We can not use a priority queue because we need to iterate over all the
> +  //! candidates and std::priority_queue doesn't provide that interface.
> +  typedef std::vector<Candidate> CandidateList;

Do you think it would be better to use a `boost::priority_queue` here?  We use it in the `CosineTree` code for this exact reason.
http://www.boost.org/doc/libs/1_55_0/doc/html/heap.html

---
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/pull/732/files/b93ee86eafb123e29830edd1876c794dc41c7878#r72306156
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160726/0bf24d28/attachment.html>


More information about the mlpack-git mailing list