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

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_find&amp;diff=2395&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_find&amp;diff=2395&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://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_find&amp;diff=2396&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B_Tutorial/list/list_find&amp;diff=2396&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:38Z</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;==Find element 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;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    list&amp;lt;int&amp;gt; coll;&lt;br /&gt;
    list&amp;lt;int&amp;gt;::iterator pos;&lt;br /&gt;
    // insert elements from 20 to 40&lt;br /&gt;
    for (int i=20; i&amp;lt;=40; ++i) {&lt;br /&gt;
        coll.push_back(i);&lt;br /&gt;
    }&lt;br /&gt;
    /* find position of element with value 3&lt;br /&gt;
     * - there is none, so pos gets coll.end()&lt;br /&gt;
     */&lt;br /&gt;
    pos = find (coll.begin(), coll.end(),    // range&lt;br /&gt;
                3);                          // value&lt;br /&gt;
    &lt;br /&gt;
    /* reverse the order of elements between found element and the end&lt;br /&gt;
     * - because pos is coll.end() it reverses an empty range&lt;br /&gt;
     */&lt;br /&gt;
    reverse (pos, coll.end());&lt;br /&gt;
    // find positions of values 25 and 35&lt;br /&gt;
    list&amp;lt;int&amp;gt;::iterator pos25, pos35;&lt;br /&gt;
    pos25 = find (coll.begin(), coll.end(),  // range&lt;br /&gt;
                  25);                       // value&lt;br /&gt;
    pos35 = find (coll.begin(), coll.end(),  // range&lt;br /&gt;
                  35);                       // value&lt;br /&gt;
    /* print the maximum of the corresponding range&lt;br /&gt;
     * - note: including pos25 but excluding pos35&lt;br /&gt;
     */&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;max: &amp;quot; &amp;lt;&amp;lt; *max_element (pos25, pos35) &amp;lt;&amp;lt; endl;&lt;br /&gt;
    // process the elements including the last position&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;max: &amp;quot; &amp;lt;&amp;lt; *max_element (pos25, ++pos35) &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;max: 34&lt;br /&gt;
max: 35&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Finding and Erasing the First or Last Matching Element==&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;functional&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
class Publication&lt;br /&gt;
{&lt;br /&gt;
   public:&lt;br /&gt;
   Publication( string first_name = &amp;quot;&amp;quot;, string last_name = &amp;quot;&amp;quot;, string title = &amp;quot;&amp;quot;, string journal = &amp;quot;&amp;quot;, int year = 0 );&lt;br /&gt;
   bool operator&amp;lt;( const Publication&amp;amp; rhs ) const;&lt;br /&gt;
   // order by date&lt;br /&gt;
   string last_name() const;&lt;br /&gt;
   void print() const;&lt;br /&gt;
   // display publication data&lt;br /&gt;
   int year() const;&lt;br /&gt;
   private:&lt;br /&gt;
   string first_name_;&lt;br /&gt;
   string journal_;&lt;br /&gt;
   string last_name_;&lt;br /&gt;
   string title_;&lt;br /&gt;
   int year_;&lt;br /&gt;
};&lt;br /&gt;
inline&lt;br /&gt;
Publication::Publication( string first_name, string last_name,&lt;br /&gt;
   string title, string journal, int year )&lt;br /&gt;
   : first_name_( first_name ), journal_( journal ),&lt;br /&gt;
      last_name_( last_name ), title_( title ), year_( year )&lt;br /&gt;
{}&lt;br /&gt;
inline&lt;br /&gt;
bool Publication::operator&amp;lt;( const Publication&amp;amp; rhs ) const&lt;br /&gt;
{  return year() &amp;lt; rhs.year(); }&lt;br /&gt;
inline&lt;br /&gt;
string Publication::last_name() const&lt;br /&gt;
{  return last_name_; }&lt;br /&gt;
inline&lt;br /&gt;
void Publication::print() const&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; last_name() &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; first_name_ &amp;lt;&amp;lt; endl&lt;br /&gt;
      &amp;lt;&amp;lt; title_ &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; journal_ &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; year()&lt;br /&gt;
      &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
inline&lt;br /&gt;
int Publication::year() const&lt;br /&gt;
{  return year_; }&lt;br /&gt;
inline&lt;br /&gt;
bool equals_last_name( const Publication publication,string last_name )&lt;br /&gt;
{  return publication.last_name() == last_name; }&lt;br /&gt;
int main( )&lt;br /&gt;
{&lt;br /&gt;
   list&amp;lt;Publication&amp;gt; publication;&lt;br /&gt;
   publication.push_back( Publication( &amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;,&amp;quot;D&amp;quot;, 1999 ) );&lt;br /&gt;
   publication.push_back( Publication( &amp;quot;E&amp;quot;, &amp;quot;F&amp;quot;,&amp;quot;G&amp;quot;,&amp;quot;H&amp;quot;, 1992 ) );&lt;br /&gt;
   publication.push_back( Publication( &amp;quot;I&amp;quot;, &amp;quot;J&amp;quot;,&amp;quot;K&amp;quot;,&amp;quot;L&amp;quot;, 1992 ) );&lt;br /&gt;
   publication.sort();&lt;br /&gt;
   cout &amp;lt;&amp;lt; publication.size() &amp;lt;&amp;lt; &amp;quot; PUBLICATIONS\n&amp;quot;;&lt;br /&gt;
   for_each( publication.begin(), publication.end(),mem_fun_ref( &amp;amp;Publication::print ) );&lt;br /&gt;
   // find earliest publication by Reese&lt;br /&gt;
   string author( &amp;quot;A&amp;quot; );&lt;br /&gt;
   list&amp;lt;Publication&amp;gt;::iterator earliest = find_if( publication.begin(), publication.end(), bind2nd( ptr_fun( equals_last_name ), author ) );&lt;br /&gt;
   // if publication found, display and delete it&lt;br /&gt;
   if( earliest != publication.end() ) {&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;\nEARLIEST PUBLICATION BY &amp;quot; &amp;lt;&amp;lt; author &amp;lt;&amp;lt; endl;&lt;br /&gt;
      earliest-&amp;gt;print();&lt;br /&gt;
      publication.erase( earliest );&lt;br /&gt;
   }&lt;br /&gt;
   else&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;NO PUBLICATIONS BY &amp;quot; &amp;lt;&amp;lt; author &amp;lt;&amp;lt; endl;&lt;br /&gt;
   // find latest publication by A&lt;br /&gt;
   list&amp;lt;Publication&amp;gt;::reverse_iterator latest = find_if( publication.rbegin(), publication.rend(), bind2nd( ptr_fun( equals_last_name ), author ) );&lt;br /&gt;
   // if publication found, display and delete it&lt;br /&gt;
   if( latest != publication.rend() ){&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;\nLATEST PUBLICATION BY &amp;quot; &amp;lt;&amp;lt; author &amp;lt;&amp;lt; endl;&lt;br /&gt;
      latest-&amp;gt;print();&lt;br /&gt;
      publication.erase( --latest.base() );&lt;br /&gt;
   }&lt;br /&gt;
   else&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;NO PUBLICATIONS BY &amp;quot; &amp;lt;&amp;lt; author &amp;lt;&amp;lt; endl;&lt;br /&gt;
   // display all remaining publications&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;THERE ARE &amp;quot; &amp;lt;&amp;lt; publication.size() &amp;lt;&amp;lt; &amp;quot; PUBLICATIONS REMAINING\n&amp;quot;;&lt;br /&gt;
   for_each( publication.begin(), publication.end(), mem_fun_ref( &amp;amp;Publication::print ) );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Find the maximum element in a range 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;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    list&amp;lt;int&amp;gt; coll;&lt;br /&gt;
    list&amp;lt;int&amp;gt;::iterator pos;&lt;br /&gt;
    // insert elements from 20 to 40&lt;br /&gt;
    for (int i=20; i&amp;lt;=40; ++i) {&lt;br /&gt;
        coll.push_back(i);&lt;br /&gt;
    }&lt;br /&gt;
    /* find position of element with value 3&lt;br /&gt;
     * - there is none, so pos gets coll.end()&lt;br /&gt;
     */&lt;br /&gt;
    pos = find (coll.begin(), coll.end(),    // range&lt;br /&gt;
                3);                          // value&lt;br /&gt;
    &lt;br /&gt;
    /* reverse the order of elements between found element and the end&lt;br /&gt;
     * - because pos is coll.end() it reverses an empty range&lt;br /&gt;
     */&lt;br /&gt;
    reverse (pos, coll.end());&lt;br /&gt;
    // find positions of values 25 and 35&lt;br /&gt;
    list&amp;lt;int&amp;gt;::iterator pos25, pos35;&lt;br /&gt;
    pos25 = find (coll.begin(), coll.end(),  // range&lt;br /&gt;
                  25);                       // value&lt;br /&gt;
    pos35 = find (coll.begin(), coll.end(),  // range&lt;br /&gt;
                  35);                       // value&lt;br /&gt;
    /* print the maximum of the corresponding range&lt;br /&gt;
     * - note: including pos25 but excluding pos35&lt;br /&gt;
     */&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;max: &amp;quot; &amp;lt;&amp;lt; *max_element (pos25, pos35) &amp;lt;&amp;lt; endl;&lt;br /&gt;
    // process the elements including the last position&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;max: &amp;quot; &amp;lt;&amp;lt; *max_element (pos25, ++pos35) &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;max: 34&lt;br /&gt;
max: 35&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>