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%2FSTL_Algorithms_Modifying_sequence_operations%2Funique_copy</id>
		<title>C++/STL Algorithms Modifying sequence operations/unique copy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FSTL_Algorithms_Modifying_sequence_operations%2Funique_copy"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/STL_Algorithms_Modifying_sequence_operations/unique_copy&amp;action=history"/>
		<updated>2026-04-16T22:15:31Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/STL_Algorithms_Modifying_sequence_operations/unique_copy&amp;diff=1929&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/STL_Algorithms_Modifying_sequence_operations/unique_copy&amp;diff=1929&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</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/STL_Algorithms_Modifying_sequence_operations/unique_copy&amp;diff=1930&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/STL_Algorithms_Modifying_sequence_operations/unique_copy&amp;diff=1930&amp;oldid=prev"/>
				<updated>2010-05-25T10:28:12Z</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;==Copy only unique elements in a vector into another vector==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   const int SIZE = 10;&lt;br /&gt;
   int a1[ SIZE ] = { 1, 3, 5, 7, 9, 1, 3, 5, 7, 9 };&lt;br /&gt;
   std::vector&amp;lt; int &amp;gt; v1( a1, a1 + SIZE ); // copy of a&lt;br /&gt;
   std::ostream_iterator&amp;lt; int &amp;gt; output( cout, &amp;quot; &amp;quot; );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Vector v1 contains: &amp;quot;;&lt;br /&gt;
   std::copy( v1.begin(), v1.end(), output );&lt;br /&gt;
   std::vector&amp;lt; int &amp;gt; results1;&lt;br /&gt;
   std::unique_copy( v1.begin(), v1.end(), std::back_inserter( results1 ) );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\nAfter unique_copy results1 contains: &amp;quot;;&lt;br /&gt;
   std::copy( results1.begin(), results1.end(), output );&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
Vector v1 contains: 1 3 5 7 9 1 3 5 7 9&lt;br /&gt;
After unique_copy results1 contains: 1 3 5 7 9 1 3 5 7 9&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Copy standard input to standard output while compressing spaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&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;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
bool bothSpaces (char elem1, char elem2)&lt;br /&gt;
{&lt;br /&gt;
    return elem1 == &amp;quot; &amp;quot; &amp;amp;&amp;amp; elem2 == &amp;quot; &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    // don&amp;quot;t skip leading whitespaces by default&lt;br /&gt;
    cin.unsetf(ios::skipws);&lt;br /&gt;
    /* copy standard input to standard output&lt;br /&gt;
     * - while compressing spaces&lt;br /&gt;
     */&lt;br /&gt;
    unique_copy(istream_iterator&amp;lt;char&amp;gt;(cin),  // beginning of source: cin&lt;br /&gt;
                istream_iterator&amp;lt;char&amp;gt;(),     // end of source: end-of-file&lt;br /&gt;
                ostream_iterator&amp;lt;char&amp;gt;(cout), // destination: cout&lt;br /&gt;
                bothSpaces);                  // duplicate criterion&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
a&lt;br /&gt;
a&lt;br /&gt;
Terminate batch job (Y/N)? n&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Read all characters while compressing whitespaces==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&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;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
#include &amp;lt;locale&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
class bothWhiteSpaces {&lt;br /&gt;
  private:&lt;br /&gt;
    const locale&amp;amp; loc;    // locale&lt;br /&gt;
  public:&lt;br /&gt;
    /* constructor&lt;br /&gt;
     * - save the locale object&lt;br /&gt;
     */&lt;br /&gt;
    bothWhiteSpaces (const locale&amp;amp; l) : loc(l) {&lt;br /&gt;
    }&lt;br /&gt;
    /* function call&lt;br /&gt;
     * - returns whether both characters are whitespaces&lt;br /&gt;
     */&lt;br /&gt;
    bool operator() (char elem1, char elem2) {&lt;br /&gt;
        return isspace(elem1,loc) &amp;amp;&amp;amp; isspace(elem2,loc);&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    string contents;&lt;br /&gt;
    // don&amp;quot;t skip leading whitespaces&lt;br /&gt;
    cin.unsetf (ios::skipws);&lt;br /&gt;
    //Read all characters while compressing whitespaces&lt;br /&gt;
    unique_copy(istream_iterator&amp;lt;char&amp;gt;(cin),    // beginning of source&lt;br /&gt;
                istream_iterator&amp;lt;char&amp;gt;(),       // end of source&lt;br /&gt;
                back_inserter(contents),        // destination&lt;br /&gt;
                bothWhiteSpaces(cin.getloc())); // criterion for removing&lt;br /&gt;
    // process contents&lt;br /&gt;
    // - here: write it to the standard output&lt;br /&gt;
    cout &amp;lt;&amp;lt; contents;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
string&lt;br /&gt;
string&lt;br /&gt;
asdf&lt;br /&gt;
&lt;br /&gt;
string&lt;br /&gt;
string&lt;br /&gt;
asdf&lt;br /&gt;
Terminate batch job (Y/N)? n&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Remove adjacent duplicates: unique_copy==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&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;
    const string hello(&amp;quot;Hello, how are you?&amp;quot;);&lt;br /&gt;
    string s(hello.begin(),hello.end());&lt;br /&gt;
    // iterate through all of the characters&lt;br /&gt;
    string::iterator pos;&lt;br /&gt;
    for (pos = s.begin(); pos != s.end(); ++pos) {&lt;br /&gt;
        cout &amp;lt;&amp;lt; *pos;&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
    /* remove adjacent duplicates&lt;br /&gt;
     * - unique() reorders and returns new end&lt;br /&gt;
     * - erase() shrinks accordingly&lt;br /&gt;
     */&lt;br /&gt;
    s.erase (unique(s.begin(), s.end()),  s.end());&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;no duplicates: &amp;quot; &amp;lt;&amp;lt; s &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
Hello, how are you?&lt;br /&gt;
no duplicates: Helo, how are you?&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Use unique_copy to copy elements in an array to list with back_inserter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &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;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main( ) {&lt;br /&gt;
   string arrStr[5] = {&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;D&amp;quot;, &amp;quot;E&amp;quot;};&lt;br /&gt;
   list&amp;lt;string&amp;gt; lstStrDest;&lt;br /&gt;
   unique_copy(&amp;amp;arrStr[0], &amp;amp;arrStr[5], back_inserter(lstStrDest));&lt;br /&gt;
   for (list&amp;lt;string&amp;gt;::iterator p = lstStrDest.begin( );&lt;br /&gt;
        p != lstStrDest.end( ); ++p) {&lt;br /&gt;
      cout &amp;lt;&amp;lt; *p &amp;lt;&amp;lt; endl;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
A&lt;br /&gt;
B&lt;br /&gt;
A&lt;br /&gt;
D&lt;br /&gt;
E&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Use unique_copy to print elements with consecutive duplicates removed==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&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;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;deque&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;set&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
#include &amp;lt;functional&amp;gt;&lt;br /&gt;
#include &amp;lt;numeric&amp;gt;&lt;br /&gt;
/* PRINT_ELEMENTS()&lt;br /&gt;
 * - prints optional C-string optcstr followed by&lt;br /&gt;
 * - all elements of the collection coll&lt;br /&gt;
 * - separated by spaces&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
inline void PRINT_ELEMENTS (const T&amp;amp; coll, const char* optcstr=&amp;quot;&amp;quot;)&lt;br /&gt;
{&lt;br /&gt;
    typename T::const_iterator pos;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; optcstr;&lt;br /&gt;
    for (pos=coll.begin(); pos!=coll.end(); ++pos) {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; *pos &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
/* INSERT_ELEMENTS (collection, first, last)&lt;br /&gt;
 * - fill values from first to last into the collection&lt;br /&gt;
 * - NOTE: NO half-open range&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
inline void INSERT_ELEMENTS (T&amp;amp; coll, int first, int last)&lt;br /&gt;
{&lt;br /&gt;
    for (int i=first; i&amp;lt;=last; ++i) {&lt;br /&gt;
        coll.insert(coll.end(),i);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
bool differenceOne (int elem1, int elem2)&lt;br /&gt;
{&lt;br /&gt;
    return elem1 + 1 == elem2 || elem1 - 1 == elem2;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    // source data&lt;br /&gt;
    int source[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7,&lt;br /&gt;
                      5, 4, 4 };&lt;br /&gt;
    int sourceNum = sizeof(source)/sizeof(source[0]);&lt;br /&gt;
    // initialize coll with elements from source&lt;br /&gt;
    list&amp;lt;int&amp;gt; coll;&lt;br /&gt;
    copy(source, source+sourceNum,      // source&lt;br /&gt;
         back_inserter(coll));          // destination&lt;br /&gt;
    PRINT_ELEMENTS(coll);&lt;br /&gt;
    // print elements with consecutive duplicates removed&lt;br /&gt;
    unique_copy(coll.begin(), coll.end(),          // source&lt;br /&gt;
                ostream_iterator&amp;lt;int&amp;gt;(cout,&amp;quot; &amp;quot;));  // destination&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
1 4 4 6 1 2 2 3 1 6 6 6 5 7 5 4 4&lt;br /&gt;
1 4 6 1 2 3 1 6 5 7 5 4&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Use unique_copy to print elements without consecutive entries that differ by one==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&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;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;deque&amp;gt;&lt;br /&gt;
#include &amp;lt;list&amp;gt;&lt;br /&gt;
#include &amp;lt;set&amp;gt;&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
#include &amp;lt;functional&amp;gt;&lt;br /&gt;
#include &amp;lt;numeric&amp;gt;&lt;br /&gt;
/* PRINT_ELEMENTS()&lt;br /&gt;
 * - prints optional C-string optcstr followed by&lt;br /&gt;
 * - all elements of the collection coll&lt;br /&gt;
 * - separated by spaces&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
inline void PRINT_ELEMENTS (const T&amp;amp; coll, const char* optcstr=&amp;quot;&amp;quot;)&lt;br /&gt;
{&lt;br /&gt;
    typename T::const_iterator pos;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; optcstr;&lt;br /&gt;
    for (pos=coll.begin(); pos!=coll.end(); ++pos) {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; *pos &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
/* INSERT_ELEMENTS (collection, first, last)&lt;br /&gt;
 * - fill values from first to last into the collection&lt;br /&gt;
 * - NOTE: NO half-open range&lt;br /&gt;
 */&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
inline void INSERT_ELEMENTS (T&amp;amp; coll, int first, int last)&lt;br /&gt;
{&lt;br /&gt;
    for (int i=first; i&amp;lt;=last; ++i) {&lt;br /&gt;
        coll.insert(coll.end(),i);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
bool differenceOne (int elem1, int elem2)&lt;br /&gt;
{&lt;br /&gt;
    return elem1 + 1 == elem2 || elem1 - 1 == elem2;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    // source data&lt;br /&gt;
    int source[] = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7,&lt;br /&gt;
                      5, 4, 4 };&lt;br /&gt;
    int sourceNum = sizeof(source)/sizeof(source[0]);&lt;br /&gt;
    // initialize coll with elements from source&lt;br /&gt;
    list&amp;lt;int&amp;gt; coll;&lt;br /&gt;
    copy(source, source+sourceNum,      // source&lt;br /&gt;
         back_inserter(coll));          // destination&lt;br /&gt;
    PRINT_ELEMENTS(coll);&lt;br /&gt;
    // print elements without consecutive entries that differ by one&lt;br /&gt;
    unique_copy(coll.begin(), coll.end(),         // source&lt;br /&gt;
                ostream_iterator&amp;lt;int&amp;gt;(cout,&amp;quot; &amp;quot;),  // destination&lt;br /&gt;
                differenceOne);                   // duplicates criterion&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
/* &lt;br /&gt;
1 4 4 6 1 2 2 3 1 6 6 6 5 7 5 4 4&lt;br /&gt;
1 4 4 6 1 3 1 6 6 6 4 4&lt;br /&gt;
 */        &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>