• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Benjamin

            靜以修身,儉以養(yǎng)德,非澹薄無以明志,非寧靜無以致遠。
            隨筆 - 397, 文章 - 0, 評論 - 196, 引用 - 0
            數據加載中……

            STL算法(Algorithms):修改操作(拷貝、替換等)

            Stl的函數對象的寫操作:
            copy、copy_backward、swap、swap_ranges、iter_swap、transform、
            replace、replace_if、replace_copy、replace_copy_if、fill、fill_n、
            generate、generate_n、remove、remove_if、remove_copy、remove_copy_if、
            unique、unique_copy、reverse、reverse_copy、rotate、rotate_copy、
            random_shuffle、partition、stable_partition
            1. 拷貝:copy和copy_backward
            Copy的原型:
            template <class InputIterator, class OutputIterator>
              OutputIterator copy ( InputIterator first, InputIterator last, OutputIterator result );
            copy_backward原型:
            template <class BidirectionalIterator1, class BidirectionalIterator2>
              BidirectionalIterator2 copy_backward ( BidirectionalIterator1 first,
                                                     BidirectionalIterator1 last,
                                                     BidirectionalIterator2 result );
            這兩個函數區(qū)別:copy是正常的拷貝,copy_backward則是從序列的末尾開始拷貝;
            copy_backward和下面的代碼等效
            template<class BidirectionalIterator1, class BidirectionalIterator2>
              BidirectionalIterator2 copy_backward ( BidirectionalIterator1 first,
                                                     BidirectionalIterator1 last,
                                                     BidirectionalIterator2 result )
            {
              while (last!=first) *(--result) = *(--last);
              return result;
            }
            Copy和下面的代碼等效
            template<class InputIterator, class OutputIterator>
              OutputIterator copy ( InputIterator first, InputIterator last, OutputIterator result )
            {
              while (first!=last) *result++ = *first++;
              return result;
            }
            copy例子:
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[]={10,20,30,40,50,60,70};
              vector<int> myvector;
              vector<int>::iterator it;

              myvector.resize(7);   // allocate space for 7 elements

              copy ( myints, myints+7, myvector.begin() );

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            copy_backward例子:
            // copy_backward example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> myvector;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<=5; i++)
                myvector.push_back(i*10);          // myvector: 10 20 30 40 50

              myvector.resize(myvector.size()+3);  // allocate space for 3 more elements

              copy_backward ( myvector.begin(), myvector.begin()+5, myvector.end() );

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            這個輸出的是myvector contains: 10 20 30 10 20 30 40 50

             

            2、交換:swap、swap_ranges、iter_swap
            Swap交換兩個對象的值;swap_ranges是交換連個范圍內的值;
            iter_swap通過迭代器交換兩個對象指針的值
            例子:
            // swap algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {

              int x=10, y=20;                         // x:10 y:20
              swap(x,y);                              // x:20 y:10

              vector<int> first (4,x), second (6,y);  // first:4x20 second:6x10
              swap(first,second);                     // first:6x10 second:4x20

              cout << "first contains:";
              for (vector<int>::iterator it=first.begin(); it!=first.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // swap_ranges example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> first (5,10);        //  first: 10 10 10 10 10
              vector<int> second (5,33);       // second: 33 33 33 33 33
              vector<int>::iterator it;

              swap_ranges(first.begin()+1, first.end()-1, second.begin());

              // print out results of swap:
              cout << " first contains:";
              for (it=first.begin(); it!=first.end(); ++it)
                cout << " " << *it;

              cout << "\nsecond contains:";
              for (it=second.begin(); it!=second.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // iter_swap example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {

              int myints[]={10,20,30,40,50 };          //   myints:  10  20  30  40  50
              vector<int> myvector (4,99);             // myvector:  99  99  99  99

              iter_swap(myints,myvector.begin());      //   myints: [99] 20  30  40  50
                                                       // myvector: [10] 99  99  99

              iter_swap(myints+3,myvector.begin()+2);  //   myints:  99  20  30 [99]
                                                       // myvector:  10  99 [40] 99

              cout << "myvector contains:";
              for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            3、替換: replace、replace_if、replace_copy、replace_copy_if
            replace是簡單的值替換;replace_if是有條件的替換;
            replace_copy是替換并重新輸出到另一個序列中;
            replace_copy_if和上面的功能類似,不過有條件;
            注意:這里如果有參數是類對象,則必須重載()
            例子:// replace algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[] = { 10, 20, 30, 30, 20, 10, 10, 20 };
              vector<int> myvector (myints, myints+8);            // 10 20 30 30 20 10 10 20

              replace (myvector.begin(), myvector.end(), 20, 99); // 10 99 30 30 99 10 10 99

              cout << "myvector contains:";
              for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // replace_if example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool IsOdd (int i) { return ((i%2)==1); }

            int main () {
              vector<int> myvector;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<10; i++) myvector.push_back(i);          // 1 2 3 4 5 6 7 8 9
             
              replace_if (myvector.begin(), myvector.end(), IsOdd, 0); // 0 2 0 4 0 6 0 8 0

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }

            // replace_copy example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[] = { 10, 20, 30, 30, 20, 10, 10, 20 };

              vector<int> myvector (8);
              replace_copy (myints, myints+8, myvector.begin(), 20, 99);

              cout << "myvector contains:";
              for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // replace_copy_if example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool IsOdd (int i) { return ((i%2)==1); }

            int main () {
              vector<int> first,second;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<10; i++) first.push_back(i);          // 1 2 3 4 5 6 7 8 9

              second.resize(first.size());   // allocate space
              replace_copy_if (first.begin(), first.end(), second.begin(), IsOdd, 0);
                                                                    // 0 2 0 4 0 6 0 8 0

              cout << "second contains:";
              for (it=second.begin(); it!=second.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }

            4、初始化:fill、fill_n、generate、generate_n
            fill和fill_n類似于memset;
            generate和generate_n通過函數來產生每個值。
            例子:
            // fill algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> myvector (8);                       // myvector: 0 0 0 0 0 0 0 0

              fill (myvector.begin(),myvector.begin()+4,5);   // myvector: 5 5 5 5 0 0 0 0
              fill (myvector.begin()+3,myvector.end()-2,8);   // myvector: 5 5 5 8 8 8 0 0

              cout << "myvector contains:";
              for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // fill_n example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> myvector (8,10);        // myvector: 10 10 10 10 10 10 10 10

              fill_n (myvector.begin(),4,20);     // myvector: 20 20 20 20 10 10 10 10
              fill_n (myvector.begin()+3,3,33);   // myvector: 20 20 20 33 33 33 10 10

              cout << "myvector contains:";
              for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // generate algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            #include <ctime>
            #include <cstdlib>
            using namespace std;

            // function generator:
            int RandomNumber () { return (rand()%100); }

            // class generator:
            struct c_unique {
              int current;
              c_unique() {current=0;}
              int operator()() {return ++current;}
            } UniqueNumber;


            int main () {
              srand ( unsigned ( time(NULL) ) );

              vector<int> myvector (8);
              vector<int>::iterator it;

              generate (myvector.begin(), myvector.end(), RandomNumber);

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              generate (myvector.begin(), myvector.end(), UniqueNumber);

              cout << "\nmyvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // generate_n example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int current(0);
            int UniqueNumber () { return ++current; }

            int main () {
              int myarray[9];

              generate_n (myarray, 9, UniqueNumber);

              cout << "myarray contains:";
              for (int i=0; i<9; ++i)
                cout << " " << myarray[i];

              cout << endl;
              return 0;
            }
            5、轉換:transform(適用于對某個序列內的每個成員進行的某個操作)
            原型:template < class InputIterator, class OutputIterator, class UnaryOperator >
              OutputIterator transform ( InputIterator first1, InputIterator last1,
                                         OutputIterator result, UnaryOperator op );

            template < class InputIterator1, class InputIterator2,
                       class OutputIterator, class BinaryOperator >
              OutputIterator transform ( InputIterator1 first1, InputIterator1 last1,
                                         InputIterator2 first2, OutputIterator result,
                                         BinaryOperator binary_op );
            例子:
            // transform algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int op_increase (int i) { return ++i; }
            int op_sum (int i, int j) { return i+j; }

            int main () {
              vector<int> first;
              vector<int> second;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<6; i++) first.push_back (i*10); //  first: 10 20 30 40 50

              second.resize(first.size());     // allocate space
              transform (first.begin(), first.end(), second.begin(), op_increase);
                                                              // second: 11 21 31 41 51

              transform (first.begin(), first.end(), second.begin(), first.begin(), op_sum);
                                                              //  first: 21 41 61 81 101

              cout << "first contains:";
              for (it=first.begin(); it!=first.end(); ++it)
                cout << " " << *it;

              cout << endl;
              return 0;
            }
            6、刪除:remove、remove_if、remove_copy、remove_copy_if、unique、unique_copy
            remove:從序列中刪除某個元素
            原型:template < class ForwardIterator, class T >
              ForwardIterator remove ( ForwardIterator first, ForwardIterator last,
                                       const T& value );
            remove_if:將符合條件的都刪除掉;remvoe和remove刪除后,序列的長度會有變化(減少)
            原型:template < class ForwardIterator, class Predicate >
              ForwardIterator remove_if ( ForwardIterator first, ForwardIterator last,
                                          Predicate pred );
            remove_copy:將刪除后的序列拷貝到另外一個序列中
            原型:template <class InputIterator, class OutputIterator, class T>
              OutputIterator remove_copy ( InputIterator first, InputIterator last,
                                           OutputIterator result, const T& value );
            remove_copy_if:基本功能和remove_copy類似,不過這里是有條件的刪除
            原型:template <class InputIterator, class OutputIterator, class Predicate>
              OutputIterator remove_copy_if ( InputIterator first, InputIterator last,
                                              OutputIterator result, Predicate pred );
            unique:刪除連續(xù)的重復的元素
            原型:template <class ForwardIterator>
              ForwardIterator unique ( ForwardIterator first, ForwardIterator last );

            template <class ForwardIterator, class BinaryPredicate>
              ForwardIterator unique ( ForwardIterator first, ForwardIterator last,
                                       BinaryPredicate pred );
            unique_copy:將刪除連續(xù)的重復的元素后的序列拷貝到另一個序列中
            原型:template <class InputIterator, class OutputIterator>
              OutputIterator unique_copy ( InputIterator first, InputIterator last,
                                           OutputIterator result );

            template <class InputIterator, class OutputIterator, class BinaryPredicate>
              OutputIterator unique_copy ( InputIterator first, InputIterator last,
                                           OutputIterator result, BinaryPredicate pred );
            示例:
            // remove algorithm example
            #include <iostream>
            #include <algorithm>
            using namespace std;

            int main () {
              int myints[] = {10,20,30,30,20,10,10,20};      // 10 20 30 30 20 10 10 20

              // bounds of range:
              int* pbegin = myints;                          // ^
              int* pend = myints+sizeof(myints)/sizeof(int); // ^                       ^

              pend = remove (pbegin, pend, 20);              // 10 30 30 10 10 ?  ?  ?
                                                             // ^              ^
              cout << "range contains:";
              for (int* p=pbegin; p!=pend; ++p)
                cout << " " << *p;

              cout << endl;
             
              return 0;
            }
            // remove_if example
            #include <iostream>
            #include <algorithm>
            using namespace std;

            bool IsOdd (int i) { return ((i%2)==1); }

            int main () {
              int myints[] = {1,2,3,4,5,6,7,8,9};            // 1 2 3 4 5 6 7 8 9

              // bounds of range:
              int* pbegin = myints;                          // ^
              int* pend = myints+sizeof(myints)/sizeof(int); // ^                 ^

              pend = remove_if (pbegin, pend, IsOdd);        // 2 4 6 8 ? ? ? ? ?
                                                             // ^       ^
              cout << "range contains:";
              for (int* p=pbegin; p!=pend; ++p)
                cout << " " << *p;

              cout << endl;
             
              return 0;
            }
            // remove_copy example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[] = {10,20,30,30,20,10,10,20};          // 10 20 30 30 20 10 10 20
              vector<int> myvector (8);
              vector<int>::iterator it;

              remove_copy (myints,myints+8,myvector.begin(),20); // 10 30 30 10 10 0 0 0

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // remove_copy_if example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool IsOdd (int i) { return ((i%2)==1); }

            int main () {
              int myints[] = {1,2,3,4,5,6,7,8,9};         
              vector<int> myvector (9);
              vector<int>::iterator it;

              remove_copy_if (myints,myints+9,myvector.begin(),IsOdd);

              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;
             
              return 0;
            }
            // unique algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool myfunction (int i, int j) {
              return (i==j);
            }

            int main () {
              int myints[] = {10,20,20,20,30,30,20,20,10};    // 10 20 20 20 30 30 20 20 10
              vector<int> myvector (myints,myints+9);
              vector<int>::iterator it;

              // using default comparison:
              it = unique (myvector.begin(), myvector.end()); // 10 20 30 20 10 ?  ?  ?  ?
                                                              //                ^

              myvector.resize( it - myvector.begin() );       // 10 20 30 20 10

              // using predicate comparison:
              unique (myvector.begin(), myvector.end(), myfunction);   // (no changes)

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // unique_copy example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool myfunction (int i, int j) {
              return (i==j);
            }

            int main () {
              int myints[] = {10,20,20,20,30,30,20,20,10};
              vector<int> myvector (9);                            // 0  0  0  0  0  0  0  0  0
              vector<int>::iterator it;

              // using default comparison:
              it=unique_copy (myints,myints+9,myvector.begin());   // 10 20 30 20 10 0  0  0  0
                                                                   //                ^

              sort (myvector.begin(),it);                          // 10 10 20 20 30 0  0  0  0
                                                                   //                ^

              // using predicate comparison:
              it=unique_copy (myvector.begin(), it, myvector.begin(), myfunction);
                                                                   // 10 20 30 20 30 0  0  0  0
                                                                   //          ^

              myvector.resize( it - myvector.begin() );            // 10 20 30

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            7、更改序列內元素的順序:reverse、reverse_copy、rotate、rotate_copy、random_shuffle、
            reverse:反轉序列
            原型:template <class BidirectionalIterator>
              void reverse ( BidirectionalIterator first, BidirectionalIterator last);
            reverse_copy:將反轉后的序列拷貝
            原型:<algorithm>
            template <class BidirectionalIterator, class OutputIterator>
              OutputIterator reverse_copy ( BidirectionalIterator first,
                                            BidirectionalIterator last, OutputIterator result );
            rotate:旋轉元素(將指定范圍內的元素移到尾部,其他的元素相對前移)
            原型:template <class ForwardIterator>
              void rotate ( ForwardIterator first, ForwardIterator middle,
                            ForwardIterator last );
            rotate_copy:將元素旋轉后并拷貝
            原型:template <class ForwardIterator, class OutputIterator>
              OutputIterator rotate_copy ( ForwardIterator first, ForwardIterator middle,
                                           ForwardIterator last, OutputIterator result );
            random_shuffle:重排序列內的隨機元素
            原型:template <class RandomAccessIterator>
              void random_shuffle ( RandomAccessIterator first, RandomAccessIterator last );

            template <class RandomAccessIterator, class RandomNumberGenerator>
              void random_shuffle ( RandomAccessIterator first, RandomAccessIterator last,
                                    RandomNumberGenerator& rand );
            示例:
            // reverse algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> myvector;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9

              reverse(myvector.begin(),myvector.end());       // 9 8 7 6 5 4 3 2 1

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // reverse_copy example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[] ={1,2,3,4,5,6,7,8,9};
              vector<int> myvector;
              vector<int>::iterator it;

              myvector.resize(9);

              reverse_copy (myints, myints+9, myvector.begin());

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // rotate algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              vector<int> myvector;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9

              rotate(myvector.begin(),myvector.begin()+3,myvector.end());
                                                              // 4 5 6 7 8 9 1 2 3

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // rotate_copy algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            int main () {
              int myints[] = {10,20,30,40,50,60,70};

              vector<int> myvector;
              vector<int>::iterator it;

              myvector.resize(7);

              rotate_copy(myints,myints+3,myints+7,myvector.begin());

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // random_shuffle example
            #include <iostream>
            #include <algorithm>
            #include <functional>
            #include <vector>
            #include <ctime>
            #include <cstdlib>
            using namespace std;

            // random generator function:
            ptrdiff_t myrandom (ptrdiff_t i) { return rand()%i;}

            // pointer object to it:
            ptrdiff_t (*p_myrandom)(ptrdiff_t) = myrandom;

            int main () {
              srand ( unsigned ( time (NULL) ) );
              vector<int> myvector;
              vector<int>::iterator it;

              // set some values:
              for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9

              // using built-in random generator:
              random_shuffle ( myvector.begin(), myvector.end() );

              // using myrandom:
              random_shuffle ( myvector.begin(), myvector.end(), p_myrandom);

              // print out content:
              cout << "myvector contains:";
              for (it=myvector.begin(); it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            8、分割序列:partition、stable_partition
            partition:按照pred制定的規(guī)則對序列進行分割
            原型:template <class BidirectionalIterator, class Predicate>
              BidirectionalIterator partition ( BidirectionalIterator first,
                                                BidirectionalIterator last, Predicate pred );
            stable_partition:基本功能和上面的類似,不同的是分割后的序列都是排序過的(順序)
            原型和partition的一樣。
            示例:
            // partition algorithm example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool IsOdd (int i) { return (i%2)==1; }

            int main () {
              vector<int> myvector;
              vector<int>::iterator it, bound;

              // set some values:
              for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9

              bound = partition (myvector.begin(), myvector.end(), IsOdd);

              // print out content:
              cout << "odd members:";
              for (it=myvector.begin(); it!=bound; ++it)
                cout << " " << *it;

              cout << "\neven members:";
              for (it=bound; it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }
            // stable_partition example
            #include <iostream>
            #include <algorithm>
            #include <vector>
            using namespace std;

            bool IsOdd (int i) { return (i%2)==1; }

            int main () {
              vector<int> myvector;
              vector<int>::iterator it, bound;

              // set some values:
              for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9

              bound = stable_partition (myvector.begin(), myvector.end(), IsOdd);

              // print out content:
              cout << "odd members:";
              for (it=myvector.begin(); it!=bound; ++it)
                cout << " " << *it;

              cout << "\neven members:";
              for (it=bound; it!=myvector.end(); ++it)
                cout << " " << *it;

              cout << endl;

              return 0;
            }

             

             

             

             

             


             

            posted on 2012-02-05 21:39 Benjamin 閱讀(1014) 評論(0)  編輯 收藏 引用 所屬分類: 泛型編程

            久久99久久99小草精品免视看| 亚洲精品视频久久久| 精品久久久久中文字幕一区| 少妇被又大又粗又爽毛片久久黑人| 久久精品国产清高在天天线| 亚洲国产成人久久综合一区77| 国产精品久久国产精麻豆99网站| 久久久久亚洲av成人网人人软件| 国产精品嫩草影院久久| jizzjizz国产精品久久| 亚洲中文字幕无码久久2020| 久久人人爽人人爽人人片AV东京热| 久久成人精品视频| 久久精品a亚洲国产v高清不卡| 欧美精品国产综合久久| 狠狠人妻久久久久久综合| 国产精品美女久久久久| 精品久久久久久成人AV| 国产精品99久久免费观看| 7777久久久国产精品消防器材| 久久久久香蕉视频| 91久久精品国产91性色也| 亚洲国产精品久久电影欧美| 久久亚洲精品无码aⅴ大香| 欧美亚洲日本久久精品| 日本精品一区二区久久久| 久久亚洲中文字幕精品一区| 狠狠精品久久久无码中文字幕| 久久久久国产精品三级网| 精品亚洲综合久久中文字幕| 久久99亚洲网美利坚合众国| 久久精品黄AA片一区二区三区| 久久亚洲精品成人av无码网站| 99久久国产主播综合精品| 青青青国产成人久久111网站| 精品久久久久久无码国产| 亚洲国产成人乱码精品女人久久久不卡 | 99久久精品午夜一区二区| 久久久女人与动物群交毛片| 久久精品成人免费看| 久久综合狠狠综合久久97色|