<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://programmingexamples.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FSTL%2FQueue</id>
		<title>CPP/STL/Queue - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://programmingexamples.net/w/index.php?action=history&amp;feed=atom&amp;title=CPP%2FSTL%2FQueue"/>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/STL/Queue&amp;action=history"/>
		<updated>2026-06-15T08:49:35Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>http://programmingexamples.net/w/index.php?title=CPP/STL/Queue&amp;diff=104&amp;oldid=prev</id>
		<title>Daviddoria: Created page with '==Queue.cpp== &lt;source lang=&quot;cpp&quot;&gt; #include &lt;iostream&gt; #include &lt;queue&gt; #include &lt;vector&gt; #include &lt;cstdlib&gt; #include &lt;algorithm&gt;  double RandomDouble(); void TestQueue(); void Fi…'</title>
		<link rel="alternate" type="text/html" href="http://programmingexamples.net/w/index.php?title=CPP/STL/Queue&amp;diff=104&amp;oldid=prev"/>
				<updated>2010-06-23T13:01:29Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;==Queue.cpp== &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;queue&amp;gt; #include &amp;lt;vector&amp;gt; #include &amp;lt;cstdlib&amp;gt; #include &amp;lt;algorithm&amp;gt;  double RandomDouble(); void TestQueue(); void Fi…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Queue.cpp==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;queue&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
&lt;br /&gt;
double RandomDouble();&lt;br /&gt;
void TestQueue();&lt;br /&gt;
void Find();&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
  TestQueue();&lt;br /&gt;
  Find();&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void TestQueue()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;TestQueue&amp;quot; &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; &amp;quot;-------------&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  std::queue &amp;lt;double&amp;gt; q;&lt;br /&gt;
&lt;br /&gt;
  for(unsigned int i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
  {&lt;br /&gt;
    q.push(RandomDouble());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  std::cout&amp;lt;&amp;lt;&amp;quot;q contains &amp;quot; &amp;lt;&amp;lt; q.size() &amp;lt;&amp;lt; &amp;quot; elements.&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
&lt;br /&gt;
  while (!q.empty())&lt;br /&gt;
  {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; q.front() &amp;lt;&amp;lt; std::endl;    //print out the first element in the queue&lt;br /&gt;
    q.pop();                      //remove the first element of the queue&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double RandomDouble()&lt;br /&gt;
{&lt;br /&gt;
  //produce a random double between 0 and 1&lt;br /&gt;
  return drand48();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Find()&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
   std::deque &amp;lt;int&amp;gt; q;&lt;br /&gt;
&lt;br /&gt;
  q.push_front(1);&lt;br /&gt;
  q.push_front(2);&lt;br /&gt;
  q.push_front(3);&lt;br /&gt;
  &lt;br /&gt;
  //5 should not be found&lt;br /&gt;
  {&lt;br /&gt;
  std::deque&amp;lt;int&amp;gt;::iterator pos = std::find( q.begin(), q.end(), 5);&lt;br /&gt;
  if ( pos == q.end())&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;not found&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    }&lt;br /&gt;
  else&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;found&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  //2 should not be found&lt;br /&gt;
  {&lt;br /&gt;
  std::deque&amp;lt;int&amp;gt;::iterator pos = std::find( q.begin(), q.end(), 2);&lt;br /&gt;
  if ( pos == q.end())&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;not found&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    }&lt;br /&gt;
  else&lt;br /&gt;
    {&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;found&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Daviddoria</name></author>	</entry>

	</feed>