Boost logo

Boost Users :

Subject: Re: [Boost-users] Need example of substitution of priority queue
From: Eric Fowler (eric.fowler_at_[hidden])
Date: 2010-05-21 23:33:53


Thank you. I can now compile with an std::vector<> as my queue, and
the default color map.

In looking at the Dijkstra example, I see it is using a
boost::mutable_queue<>, which has the primary feature of being able to
dynamically change the sorting criterion. This is exciting but not
something I need.

Turning my attention to boost::queue<>, I am trying to see how to
place my own sorting criteria. It looks like I need to define a class
encapsulating my data (or deriving from the class that holds my data),
and to define the usual ordering operators (<,>,==, etc) within that
class. I would then declare an object of type boost::queue<MyClass>
and go from there.

Is that the "cheapest" way to get a priority queue with a custom sort order?

Eric

On Fri, May 21, 2010 at 1:13 PM, Jeremiah Willcock <jewillco_at_[hidden]> wrote:
> On Thu, 20 May 2010, Eric Fowler wrote:
>
>> I don't see how this substitutes a hand-rolled queue.
>
> That code I pointed to creates a queue and uses it in breadth_first_search.
>
>> And I don't see why this:
>>
>>                boost::bfs_visitor<null_visitor> nv;
>>                std::stack<T> q;
>>
>>                breadth_first_search(graph, vertex, q, nv);
>>
>> Is getting me this:
>>
>> In file included from MyDialog.h:8,
>>                from MyDialog.cpp:2:
>> ../DelaunayGraph/DelaunayGraph.h: In member function ‘Vertex
>> DelaunayGraph<T>::seek_vertex_nearest_point(const POS<T>&) const [with
>> T = short int]’:
>> MyDialog.cpp:44:   instantiated from here
>> ../DelaunayGraph/DelaunayGraph.h:214: error: no matching function for
>> call to ‘breadth_first_search(const DelaunayGraph<short int>&, const
>> Vertex&, std::stack<short int, std::deque<short int,
>> std::allocator<short int> > >&,
>> boost::bfs_visitor<boost::null_visitor>&)’
>> make: *** [MyDialog.o] Error 1
>
> It appears that the version of breadth_first_search that takes an explicit
> queue without using named parameters needs an explicitly specified color map
> as well.
>
> -- Jeremiah Willcock
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net