std::search_n
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
| Defined in header <algorithm>
|
||
| template< class ForwardIt, class Size, class T > ForwardIt1 search_n( ForwardIt first, ForwardIt last, Size count, const T& value ); |
(1) | |
| template< class ForwardIt, class Size, class T, class BinaryPredicate > ForwardIt1 search_n( ForwardIt first, ForwardIt last, Size count, const T& value, |
(2) | |
[first, last) gamma per la prima sequenza di conteggio elementi identici, ciascuno pari al valore determinato valore. La prima versione utilizza operator== di confrontare gli elementi, la seconda versione utilizza il predicato binario dato p.[first, last) for the first sequence of count identical elements, each equal to the given value value. The first version uses operator== to compare the elements, the second version uses the given binary predicate p.You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica] Parametri
| first, last | - | la gamma di elementi da esaminare
Original: the range of elements to examine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| count | - | la lunghezza della sequenza di ricerca
Original: the length of the sequence to search for The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| value | - | il valore degli elementi da ricercare
Original: the value of the elements to search for The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| p | - | binary predicate which returns true if the elements should be treated as equal. The signature of the predicate function should be equivalent to the following: bool pred(const Type1 &a, const Type2 &b); The signature does not need to have const &, but the function must not modify the objects passed to it. |
| Type requirements | ||
-ForwardIt must meet the requirements of ForwardIterator.
| ||
[modifica] Valore di ritorno
[first, last) gamma. In assenza di tale sequenza viene trovato, viene restituito last.[first, last). If no such sequence is found, last is returned.You can help to correct and verify the translation. Click here for instructions.
[modifica] Complessità
last - first del predicato.last - first applications of the predicate.You can help to correct and verify the translation. Click here for instructions.
[modifica] Possibile implementazione
| First version |
|---|
template<class ForwardIt, class Size, class T> ForwardIt1 search_n(ForwardIt first, ForwardIt last, Size count, const T& value) { Size curr_count = 0; ForwardIt result, t_last = first; std::advance(t_last, std::distance(first, last) - count + 1); for (; first != t_last; first++) { curr_count = 0; result = first; while (*first == value) { curr_count++; if (curr_count == count) { return result; } ++first; } } return last; } |
| Second version |
template<class ForwardIt, class Size, class T, class BinaryPredicate> ForwardIt1 search_n(ForwardIt first, ForwardIt last, Size count, const T& value, BinaryPredicate p) { Size curr_count = 0; ForwardIt result, t_last = first; std::advance(t_last, std::distance(first, last) - count + 1); for (; first != t_last; first++) { curr_count = 0; result = first; while (p(*first == value)) { curr_count++; if (curr_count == count) { return result; } ++first; } } return last; } |
[modifica] Esempio
| This section is incomplete |
[modifica] Vedi anche
| trova l'ultima sequenza di elementi di un certo intervallo Original: finds the last sequence of elements in a certain range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
| (C++11) |
trova il primo elemento che soddisfi i criteri specifici Original: finds the first element satisfying specific criteria The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) |
| searches for a range of elements (funzione di modello) | |