A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Flist%2Flist_reverse</id>
		<title>C++ Tutorial/list/list reverse - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2Flist%2Flist_reverse"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_reverse&amp;action=history"/>
		<updated>2026-04-10T21:54:52Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_reverse&amp;diff=2363&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_reverse&amp;diff=2363&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_reverse&amp;diff=2364&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_reverse&amp;diff=2364&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:32Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Accessing a Container&amp;quot;s Elements in Reverse==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;functional&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
template &amp;lt;class ForwIter&amp;gt;&lt;br /&gt;
void print(ForwIter first, ForwIter last, const char* title)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; title &amp;lt;&amp;lt; endl;&lt;br /&gt;
   while ( first != last)&lt;br /&gt;
      cout &amp;lt;&amp;lt; *first++ &amp;lt;&amp;lt; &amp;quot;\t&amp;quot;;&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
class Card&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
   enum Suit { spades, clubs, hearts, diamonds };&lt;br /&gt;
   Card( int value = 1, Suit suit = spades );&lt;br /&gt;
   // value - 1 = Ace, 2-10, 11 = Jack, 12 = Queen, 13 = King&lt;br /&gt;
   bool operator&amp;lt;( const Card&amp;amp; rhs ) const;&lt;br /&gt;
   void print() const;&lt;br /&gt;
   int suit() const;&lt;br /&gt;
   int value() const;&lt;br /&gt;
   private:&lt;br /&gt;
   int value_;&lt;br /&gt;
   Suit suit_;&lt;br /&gt;
}; &lt;br /&gt;
inline&lt;br /&gt;
Card::Card( int value, Suit suit )&lt;br /&gt;
   : value_( value ), suit_( suit )&lt;br /&gt;
{} // empty&lt;br /&gt;
inline&lt;br /&gt;
bool Card::operator&amp;lt;( const Card&amp;amp; rhs ) const&lt;br /&gt;
{ return value() &amp;lt; rhs.value(); }&lt;br /&gt;
void Card::print() const&lt;br /&gt;
{&lt;br /&gt;
   if( value() &amp;gt;= 2 &amp;amp;&amp;amp; value() &amp;lt;= 10 )&lt;br /&gt;
      cout &amp;lt;&amp;lt; value();&lt;br /&gt;
   else&lt;br /&gt;
      switch( value() )&lt;br /&gt;
      {&lt;br /&gt;
         case  1: cout &amp;lt;&amp;lt; &amp;quot;Ace&amp;quot;; break;&lt;br /&gt;
         case 11: cout &amp;lt;&amp;lt; &amp;quot;Jack&amp;quot;; break;&lt;br /&gt;
         case 12: cout &amp;lt;&amp;lt; &amp;quot;Queen&amp;quot;; break;&lt;br /&gt;
         case 13: cout &amp;lt;&amp;lt; &amp;quot;King&amp;quot;; break;&lt;br /&gt;
      };&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot; of &amp;quot;;&lt;br /&gt;
   switch( suit() )&lt;br /&gt;
   {&lt;br /&gt;
      case spades: cout &amp;lt;&amp;lt; &amp;quot;spades&amp;quot;; break;&lt;br /&gt;
      case clubs: cout &amp;lt;&amp;lt; &amp;quot;clubs&amp;quot;; break;&lt;br /&gt;
      case diamonds: cout &amp;lt;&amp;lt; &amp;quot;diamonds&amp;quot;; break;&lt;br /&gt;
      case hearts: cout &amp;lt;&amp;lt; &amp;quot;hearts&amp;quot;; break;&lt;br /&gt;
   default: cout &amp;lt;&amp;lt; &amp;quot;unknown suit&amp;quot;; break;&lt;br /&gt;
     }&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
inline&lt;br /&gt;
int Card::suit() const&lt;br /&gt;
{ return suit_; }&lt;br /&gt;
inline&lt;br /&gt;
int Card::value() const&lt;br /&gt;
{ return value_; }&lt;br /&gt;
int main( )&lt;br /&gt;
{ &lt;br /&gt;
   list&amp;lt;Card&amp;gt; hand;&lt;br /&gt;
   hand.push_back( Card( 12, Card::hearts ) );&lt;br /&gt;
   hand.push_back( Card( 6, Card::clubs ) );&lt;br /&gt;
   hand.push_back( Card( 12, Card::diamonds ) );&lt;br /&gt;
   hand.push_back( Card( 1, Card::spades ) );&lt;br /&gt;
   hand.push_back( Card( 11, Card::clubs ) );&lt;br /&gt;
   hand.sort();&lt;br /&gt;
   for_each( hand.begin(), hand.end(), mem_fun_ref( &amp;amp;Card::print ) );&lt;br /&gt;
   for_each( hand.rbegin(), hand.rend(), mem_fun_ref( &amp;amp;Card::print ) );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reversing Elements in a list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void PrintListContents (const list &amp;lt;int&amp;gt;&amp;amp; listInput);&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
    std::list &amp;lt;int&amp;gt; listIntegers;&lt;br /&gt;
    listIntegers.push_front (4);&lt;br /&gt;
    listIntegers.push_front (3);&lt;br /&gt;
    listIntegers.push_front (2);&lt;br /&gt;
    listIntegers.push_front (1);&lt;br /&gt;
    listIntegers.push_front (0);&lt;br /&gt;
    listIntegers.push_back (5);&lt;br /&gt;
    PrintListContents (listIntegers);&lt;br /&gt;
    listIntegers.reverse ();&lt;br /&gt;
    PrintListContents (listIntegers);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
void PrintListContents (const list &amp;lt;int&amp;gt;&amp;amp; listInput)&lt;br /&gt;
{&lt;br /&gt;
    if (listInput.size () &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        std::list &amp;lt;int&amp;gt;::const_iterator i;&lt;br /&gt;
        for ( i = listInput.begin (); i != listInput.end (); ++ i )&lt;br /&gt;
            cout &amp;lt;&amp;lt; *i &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot;List is empty!&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use reverse function on list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;cassert&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;  // for reverse&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  string s(&amp;quot;asdfg&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  list&amp;lt;char&amp;gt; list1(s.begin(), s.end());&lt;br /&gt;
  list&amp;lt;char&amp;gt;::iterator i;&lt;br /&gt;
  for (i = list1.begin(); i != list1.end(); ++i)&lt;br /&gt;
    cout &amp;lt;&amp;lt; *i;&lt;br /&gt;
&lt;br /&gt;
  reverse(list1.begin(), list1.end());&lt;br /&gt;
  for (i = list1.begin(); i != list1.end(); ++i)&lt;br /&gt;
    cout &amp;lt;&amp;lt; *i;&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;asdfggfdsa&amp;quot;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>