adjacent_difference
Art arda arasındaki farklar her öğe ve öncülü giriş aralığındaki hesaplar hedef aralık sonuçları verir ya da fark işlemi başka belirtilen ikili işlem burada yerini Genelleştirilmiş bir yordamın sonucu hesaplar.
template<class InputIterator, class OutIterator>
OutputIterator adjacent_difference(
InputIterator _First,
InputIterator _Last,
OutputIterator _Result
);
template<class InputIterator, class OutIterator, class BinaryOperation>
OutputIterator adjacent_difference(
InputIterator _First,
InputIterator _Last,
OutputIterator _Result,
BinaryOperation _Binary_op
);
Parametreler
_First
Öğeleri ile ilgili kendi öncülleri differenced için ya da değer çifti tarafından başka bir fonksiyona olduğu giriş aralığındaki ilk öğe adresleme giriş Yineleyici ikili işlem belirtti._Last
Öğeleri ile ilgili kendi öncülleri differenced için ya da değer çifti tarafından başka bir fonksiyona olduğu giriş aralığındaki son öğe adresleme giriş Yineleyici ikili işlem belirtti._Result
Çıkış Yineleyici farklılıklar veya belirtilen işlemin sonuçları dizisi depolanmış olduğu hedef aralığın ilk öğe adresleme._Binary_op
Fark kayıt yordamı çıkarma işlemi yerine Genelleştirilmiş işlem uygulanmış olan ikili işlem.
Dönüş Değeri
Hedef aralığın sonuna adresleme çıktı Yineleyici: _Result + ()_Last - _First).
Notlar
Çıkış Yineleyici _sonucu giriş Yineleyici olarak aynı Yineleyici olmasına izin verilen _First, , adjacent_differences yerde hesaplanmış.
Değerleri bir dizi için bir1, bir2, birbir giriş aralığındaki ilk şablon işlevi 3 depolar art arda partial_differences bir1, bir2 - bir1, a3 – birhedef aralıktaki 2.
Değerleri bir dizi için bir1, bir2, birbir giriş aralığındaki ikinci şablon işlevi 3 depolar art arda partial_differences bir1, bir2 _Binary_opbir1, bir3 _Binary_opbirhedef aralıktaki 2.
İkili işlem _Binary_op ilişkilendirilebilir ya da yer değiştirebilme olması için gerekli değildir, işlem sırası uygulandığından tamamen belirtilir.
adjacent_differenceiki ilişkili formlar:
Checked Yineleyici formlardan birini geçirmek, adjacent_difference, checked Yineleyici davranış alın. Denetlenmeyen bir yineleyici aktarýrsanýz, denetlenmeyen davranışı elde etmek.Daha fazla bilgi için bkz. İşaretli Yineleyiciler.
Örnek
// numeric_adj_diff.cpp
// compile with: /EHsc
#include <vector>
#include <list>
#include <numeric>
#include <functional>
#include <iostream>
int main( )
{
using namespace std;
vector<int> V1( 10 ), V2( 10 );
vector<int>::iterator VIter1, VIter2, VIterend, VIterend2;
list <int> L1;
list <int>::iterator LIter1, LIterend, LIterend2;
int t;
for ( t = 1 ; t <= 10 ; t++ )
{
L1.push_back( t * t );
}
cout << "The input list L1 is:\n ( " ;
for ( LIter1 = L1.begin( ) ; LIter1 != L1.end( ) ; LIter1++ )
cout << *LIter1 << " ";
cout << ")." << endl;
// The first member function for the adjacent_differences of
// elements in a list output to a vector
VIterend = adjacent_difference ( L1.begin ( ) , L1.end ( ) ,
V1.begin ( ) );
cout << "Output vector containing adjacent_differences is:\n ( " ;
for ( VIter1 = V1.begin( ) ; VIter1 != VIterend ; VIter1++ )
cout << *VIter1 << " ";
cout << ")." << endl;
// The second member function used to compute
// the adjacent products of the elements in a list
VIterend2 = adjacent_difference ( L1.begin ( ) , L1.end ( ) , V2.begin ( ) ,
multiplies<int>( ) );
cout << "The output vector with the adjacent products is:\n ( " ;
for ( VIter2 = V2.begin( ) ; VIter2 != VIterend2 ; VIter2++ )
cout << *VIter2 << " ";
cout << ")." << endl;
// Computation of adjacent_differences in place
LIterend2 = adjacent_difference ( L1.begin ( ) , L1.end ( ) , L1.begin ( ) );
cout << "In place output adjacent_differences in list L1 is:\n ( " ;
for ( LIter1 = L1.begin( ) ; LIter1 != LIterend2 ; LIter1++ )
cout << *LIter1 << " ";
cout << ")." << endl;
}
Çıktı
The input list L1 is:
( 1 4 9 16 25 36 49 64 81 100 ).
Output vector containing adjacent_differences is:
( 1 3 5 7 9 11 13 15 17 19 ).
The output vector with the adjacent products is:
( 1 4 36 144 400 900 1764 3136 5184 8100 ).
In place output adjacent_differences in list L1 is:
( 1 3 5 7 9 11 13 15 17 19 ).
Gereksinimler
Başlık: <numeric>
Namespace: std