<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: Heaps and Priority Queues in C++ &#8211; Part 3: Queues and Priority Queues	</title>
	<atom:link href="https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Fri, 01 Jun 2018 15:04:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/#comment-1034</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Fri, 01 Jun 2018 15:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2904#comment-1034</guid>

					<description><![CDATA[Another way to implement a priority-queue is to use a multi-map. A map is always sorted by its key. So if the key is the priority (0 being highest, 999 the lowest etc) and the mapped-value is the associated data, then .begin() will always point to the highest priority (lowest key) (or one of the highest priority) and equal_range() returns iterators to all elements that have the same priority. 

So to get the iterators to the current highest priority

auto priors = mymap.equal_range((mymap.begin())-&#062;first);


and to erase the elements with equal priority


mymap.erase(priors.first, priors.second);


New elements can be just inserted as multi-map properties mean that they are inserted in the right priority.


Unless you really need a heap-type tree structure to access other elements, we&#039;ve found this way to be fairly simple and fast for large queues.]]></description>
			<content:encoded><![CDATA[<p>Another way to implement a priority-queue is to use a multi-map. A map is always sorted by its key. So if the key is the priority (0 being highest, 999 the lowest etc) and the mapped-value is the associated data, then .begin() will always point to the highest priority (lowest key) (or one of the highest priority) and equal_range() returns iterators to all elements that have the same priority. </p>
<p>So to get the iterators to the current highest priority</p>
<p>auto priors = mymap.equal_range((mymap.begin())-&gt;first);</p>
<p>and to erase the elements with equal priority</p>
<p>mymap.erase(priors.first, priors.second);</p>
<p>New elements can be just inserted as multi-map properties mean that they are inserted in the right priority.</p>
<p>Unless you really need a heap-type tree structure to access other elements, we&#8217;ve found this way to be fairly simple and fast for large queues.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/#comment-888</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Tue, 27 Mar 2018 07:01:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2904#comment-888</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/#comment-886&quot;&gt;Andrew Starikov&lt;/a&gt;.

Absolutely, I&#039;ve added them now, thanks!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/#comment-886">Andrew Starikov</a>.</p>
<p>Absolutely, I&#8217;ve added them now, thanks!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Andrew Starikov		</title>
		<link>https://www.fluentcpp.com/2018/03/20/heaps-and-priority-queues-in-c-part-3-queues-and-priority-queues/#comment-886</link>

		<dc:creator><![CDATA[Andrew Starikov]]></dc:creator>
		<pubDate>Mon, 26 Mar 2018 14:40:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2904#comment-886</guid>

					<description><![CDATA[No links in the beginning (series) and end (related) of the post]]></description>
			<content:encoded><![CDATA[<p>No links in the beginning (series) and end (related) of the post</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
