Bug 18174 - documentation example for std::priority_queue usage
Summary: documentation example for std::priority_queue usage
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.1
: P2 enhancement
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks: 50800
  Show dependency treegraph
 
Reported: 2004-10-27 11:37 UTC by anonymous user
Modified: 2015-04-16 17:55 UTC (History)
1 user (show)

See Also:
Host: all
Target: all
Build: all
Known to work:
Known to fail:
Last reconfirmed: 2005-07-02 01:34:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description anonymous user 2004-10-27 11:37:18 UTC
I just wanted to add an std::priority_queue usage example in the documentations,
since it's not obvious when you don't know how tu use it.

Since there isn't an "html" target in the root Makefile of gcc i didn't check
for validity of the patch, but i think it's ok.

$ uuencode priority_queue-3.4.1.patch.uu < priority_queue-3.4.1.patch          
                                                          
begin 600 priority_queue-3.4.1.patch.uu
M9&EF9B`M<G4@+W9A<B]S86UB85]P=6)L:6,O9V-C+V=C8RTS+C0N,2YO<FEG
M+VQI8G-T9&,K*RUV,R]I;F-L=61E+V)I=',O<W1L7W%U975E+F@@+W9A<B]S
M86UB85]P=6)L:6,O9V-C+V=C8RTS+C0N,2]L:6)S=&1C*RLM=C,O:6YC;'5D
M92]B:71S+W-T;%]Q=65U92YH"BTM+2`O=F%R+W-A;6)A7W!U8FQI8R]G8V,O
M9V-C+3,N-"XQ+F]R:6<O;&EB<W1D8RLK+78S+VEN8VQU9&4O8FET<R]S=&Q?
M<75E=64N:`DR,#`T+3$P+3(W(#$R.C,Y.C(V+C`P,#`P,#`P,"`K,#(P,`HK
M*RL@+W9A<B]S86UB85]P=6)L:6,O9V-C+V=C8RTS+C0N,2]L:6)S=&1C*RLM
M=C,O:6YC;'5D92]B:71S+W-T;%]Q=65U92YH"3(P,#0M,3`M,C<@,3,Z,C0Z
M,C0N,#`P,#`P,#`P("LP,C`P"D!`("TQ,#$L-R`K,3`Q+#8S($!`"B`@("`J
M("!-96UB97)S(&YO="!F;W5N9"!I;B`B;F]R;6%L(B!C;VYT86EN97)S(&%R
M92!`8R!C;VYT86EN97)?='EP92P*("`@("H@('=H:6-H(&ES(&$@='EP961E
M9B!F;W(@=&AE('-E8V]N9"!397%U96YC92!P87)A;65T97(L(&%N9"!`8R!P
M=7-H(&%N9`H@("`@*B`@0&,@<&]P+"!W:&EC:"!A<F4@<W1A;F1A<F0@)7%U
M975E+T9)1D\@;W!E<F%T:6]N<RX*+2`@*B\**R`@("H**R`@("H@(%QB($5X
M86UP;&4Z"BL@("`J("!<8V]D90HK("`@*B`@(VEN8VQU9&4@/&EO<W1R96%M
M/@HK("`@*B`@(VEN8VQU9&4@/'9E8W1O<CX**R`@("H@("-I;F-L=61E(#QQ
M=65U93X**R`@("H**R`@("H@(&-L87-S($EN=`HK("`@*B`@>PHK("`@*B`@
M<'5B;&EC.@HK("`@*B`@("`@($EN="AI;G0@:2D**R`@("H@("`@("`@("`@
M.B!I7RAI*0HK("`@*B`@("`@('L**R`@("H@("`@("!]"BL@("`J"BL@("`J
M("`@("`@:6YT(&E?.PHK("`@*B`@?3L**R`@("H**R`@("H@('-T9#HZ;W-T
M<F5A;2`F"BL@("`J("!O<&5R871O<CP\("AS=&0Z.F]S=')E86T@)B!O<RP@
M8V]N<W0@26YT("8@:2D**R`@("H@('L**R`@("H@("`@("!R971U<FX@;W,@
M/#P@:2YI7SL**R`@("H@('T**R`@("H**R`@("H@(&-L87-S($EN=%]L97-S
M"BL@("`J("!["BL@("`J("!P=6)L:6,Z"BL@("`J("`@("`@+R\@1G5N8W1I
M;VX@;W!E<F%T;W(**R`@("H@("`@("!B;V]L(&]P97)A=&]R*"D@*&-O;G-T
M($EN="`J(&DQ+"!C;VYS="!);G0@*B!I,BD**R`@("H@("`@("!["BL@("`J
M("`@("`@("`@(')E='5R;B!I,2T^:5\@/"!I,BT^:5\["BL@("`J("`@("`@
M?0HK("`@*B`@?3L**R`@("H**R`@("H@('1Y<&5D968@<W1D.CIV96-T;W(\
M($EN="`J(#X@=F5C=&]R7W1Y<&4["BL@("`J("!T>7!E9&5F('-T9#HZ<')I
M;W)I='E?<75E=64\($EN="`J+"!V96-T;W)?='EP92P@26YT7VQE<W,@/B!P
M<FEO<FET>5]Q=65U95]T>7!E.PHK("`@*@HK("`@*B`@=F]I9`HK("`@*B`@
M9F]O*"D**R`@("H@('L**R`@("H@("`@("!V96-T;W)?='EP92!V.PHK("`@
M*@HK("`@*B`@("`@('8N<'5S:%]B86-K*&YE=R!);G0H."DI.PHK("`@*B`@
M("`@('8N<'5S:%]B86-K*&YE=R!);G0H,2DI.PHK("`@*B`@("`@('8N<'5S
M:%]B86-K*&YE=R!);G0H-2DI.PHK("`@*@HK("`@*B`@("`@('!R:6]R:71Y
M7W%U975E7W1Y<&4@<'$H=BYB96=I;B@I+"!V+F5N9"@I*3L**R`@("H**R`@
M("H@("`@("!W:&EL92`H(7!Q+F5M<'1Y*"DI"BL@("`J("`@("`@>PHK("`@
M*B`@("`@("`@("!S=&0Z.F-O=70@/#P@*G!Q+G1O<"@I(#P\('-T9#HZ96YD
M;#L**R`@("H@("`@("`@("`@9&5L971E('!Q+G1O<"@I.PHK("`@*B`@("`@
M("`@("!P<2YP;W`H*3L**R`@("H@("`@("!]"BL@("`J("!]"BL@("`J("!<
M96YD8V]D90HK("`@*B\*("`@=&5M<&QA=&4\='EP96YA;64@7U1P+"!T>7!E
H;F%M92!?4V5Q=65N8V4^"B`@("`@8VQA<W,@<75E=64*("`@("!["@``
`
end

for easy viewing (i don't know if posting the patch in plain text is ok because
of space breaking):

diff -ru
/var/samba_public/gcc/gcc-3.4.1.orig/libstdc++-v3/include/bits/stl_queue.h
/var/samba_public/gcc/gcc-3.4.1/libstdc++-v3/include/bits/stl_queue.h
--- /var/samba_public/gcc/gcc-3.4.1.orig/libstdc++-v3/include/bits/stl_queue.h 
2004-10-27 12:39:26.000000000 +0200
+++ /var/samba_public/gcc/gcc-3.4.1/libstdc++-v3/include/bits/stl_queue.h      
2004-10-27 13:24:24.000000000 +0200
@@ -101,7 +101,63 @@
    *  Members not found in "normal" containers are @c container_type,
    *  which is a typedef for the second Sequence parameter, and @c push and
    *  @c pop, which are standard %queue/FIFO operations.
-  */
+   *
+   *  \b Example:
+   *  \code
+   *  #include <iostream>
+   *  #include <vector>
+   *  #include <queue>
+   *
+   *  class Int
+   *  {
+   *  public:
+   *      Int(int i)
+   *          : i_(i)
+   *      {
+   *      }
+   *
+   *      int i_;
+   *  };
+   *
+   *  std::ostream &
+   *  operator<< (std::ostream & os, const Int & i)
+   *  {
+   *      return os << i.i_;
+   *  }
+   *
+   *  class Int_less
+   *  {
+   *  public:
+   *      // Function operator
+   *      bool operator() (const Int * i1, const Int * i2)
+   *      {
+   *          return i1->i_ < i2->i_;
+   *      }
+   *  };
+   *
+   *  typedef std::vector< Int * > vector_type;
+   *  typedef std::priority_queue< Int *, vector_type, Int_less >
priority_queue_type;
+   *
+   *  void
+   *  foo()
+   *  {
+   *      vector_type v;
+   *
+   *      v.push_back(new Int(8));
+   *      v.push_back(new Int(1));
+   *      v.push_back(new Int(5));
+   *
+   *      priority_queue_type pq(v.begin(), v.end());
+   *
+   *      while (!pq.empty())
+   *      {
+   *          std::cout << *pq.top() << std::endl;
+   *          delete pq.top();
+   *          pq.pop();
+   *      }
+   *  }
+   *  \endcode
+   */
   template<typename _Tp, typename _Sequence>
     class queue
     {


HTH
Comment 1 Andrew Pinski 2004-10-27 11:45:27 UTC
Could you send your patch to gcc-patches@ and libstdc++@?  Also could you make it off the HEAD (aka 
4.0.0)?
Comment 2 anonymous user 2004-10-27 12:00:04 UTC
(In reply to comment #1)
> Could you send your patch to gcc-patches@ and libstdc++@?  Also could you make
it off the HEAD (aka 
> 4.0.0)?

I can send it to these mailing lists but i can't download the all gcc CVS, so
not on 4.0.0.
Comment 3 Andrew Pinski 2005-07-02 01:34:26 UTC
Confirmed.
Comment 4 paolo@gcc.gnu.org 2005-11-06 13:07:21 UTC
Subject: Bug 18174

Author: paolo
Date: Sun Nov  6 13:07:11 2005
New Revision: 106560

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106560
Log:
2005-11-06  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/18174
	* include/bits/stl_queue.h (priority_queue): Tweak a bit the
	comment describing the container.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_queue.h

Comment 5 paolo@gcc.gnu.org 2005-11-06 13:09:55 UTC
Subject: Bug 18174

Author: paolo
Date: Sun Nov  6 13:09:50 2005
New Revision: 106561

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106561
Log:
2005-11-06  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/18174
	* include/bits/stl_queue.h (priority_queue): Tweak a bit the
	comment describing the container.

Modified:
    branches/gcc-4_0-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_0-branch/libstdc++-v3/include/bits/stl_queue.h

Comment 6 Paolo Carlini 2005-11-06 13:10:36 UTC
Fixed for 4.0.3.