home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 May / VPR9705A.ISO / VPR_DATA / PROGRAM / CBTRIAL / SETUP / DATA.Z / QUEUE.CPP < prev    next >
Text File  |  1997-02-14  |  798b  |  44 lines

  1.  #include <queue>
  2.  #include <string>
  3.  #include <deque>
  4.  #include <list>
  5.  
  6.  using namespace std;
  7.  
  8.  int main ()
  9.  {
  10.    //
  11.    // Make a queue using a deque container.
  12.    //
  13.    queue<int, list<int> > q;
  14.    //
  15.    // Push a couple of values on then pop them off.
  16.    //
  17.    q.push(1);
  18.    q.push(2);
  19.    cout << q.front() << endl;
  20.    q.pop();
  21.    cout << q.front() << endl;
  22.    q.pop();
  23.    //
  24.    // Make a queue of strings using a deque container.
  25.    //
  26.    queue<string,deque<string> > qs;
  27.    //
  28.    // Push on a few strings then pop them back off.
  29.    //
  30.    int i;
  31.    for (i = 0; i < 10; i++)
  32.    {
  33.      qs.push(string(i+1,'a'));
  34.      cout << qs.front() << endl;
  35.    }
  36.    for (i = 0; i < 10; i++)
  37.    {
  38.      cout << qs.front() << endl;
  39.      qs.pop();
  40.    }
  41.  
  42.    return 0;
  43.  }
  44.