[GeekBand]STLと汎型プログラミング-3

9866 ワード

このノートは主に各アルゴリズムの関数テンプレートを一覧表示します.変異アルゴリズム
for_each
template 
    Function for_each (InputIterator first, InputIterator last, Function fn);
find
template 
    InputIterator find (InputIterator first, InputIterator last, const T& val);
find_if
template 
    InputIterator find_if (InputIterator first, 
                           InputIterator last, 
                           UnaryPredicate pred);
adjacent_find
// equality version
template 
    ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last);

// predicate version
template 
    ForwardIterator adjacent_find (ForwardIterator first, ForwardIterator last,
                                   BinaryPredicate pred);
find_first_保存先
// equality version
template 
    ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1,
                                    ForwardIterator2 first2, ForwardIterator2 last2);

// predicate version
template 
    ForwardIterator1 find_first_of (ForwardIterator1 first1, ForwardIterator1 last1,
                                    ForwardIterator2 first2, ForwardIterator2 last2,
                                    BinaryPredicate pred);
count
template 
    typename iterator_traits::difference_type
    count (InputIterator first, InputIterator last, const T& val);
count_if
template 
    typename iterator_traits::difference_type
    count_if (InputIterator first, InputIterator last, UnaryPredicate pred);
mismatch
// equality version
template 
    pair
    mismatch (InputIterator1 first1, InputIterator1 last1,
              InputIterator2 first2, InputIterator2 last2);

// predicate version
template 
    pair
    mismatch (InputIterator1 first1, InputIterator1 last1,
              InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred);
equal
// equality version
template 
    bool equal (InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2);

// predicate version
template 
    bool equal (InputIterator1 first1, InputIterator1 last1,
                InputIterator2 first2, InputIterator2 last2, BinaryPredicate pred);
search
// equality version
template 
    ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1,
                             ForwardIterator2 first2, ForwardIterator2 last2);

// predicate version
template 
    ForwardIterator1 search (ForwardIterator1 first1, ForwardIterator1 last1,
                             ForwardIterator2 first2, ForwardIterator2 last2,
                             BinaryPredicate pred);
変異アルゴリズム
copy
// copy
template 
    OutputIterator copy (InputIterator first, InputIterator last,
                         OutputIterator result);

// copy_n
template 
    OutputIterator copy_n (InputIterator first, Size n, 
                           OutputIterator result);

// copy_backward
template 
    BidirectionalIterator2 copy_backward (BidirectionalIterator1 first,
                                          BidirectionalIterator1 last,
                                          BidirectionalIterator2 result);

// copy_if
template 
    OutputIterator copy_if (InputIterator first, InputIterator last,
                            OutputIterator result, UnaryPredicate pred);
swap
// swap
template  void swap (T& a, T& b);

// swap_ranges
template 
    ForwardIterator2 swap_ranges (ForwardIterator1 first1, ForwardIterator1 last1,
                                  ForwardIterator2 first2);
トランスフォーム
// unary operation
template 
    OutputIterator transform (InputIterator first1, InputIterator last1,
                              OutputIterator result, UnaryOperation op);

// binary operation
template 
    OutputIterator transform (InputIterator1 first1, InputIterator1 last1,
                              InputIterator2 first2, OutputIterator result,
                              BinaryOperation binary_op);
replace
// replace
template 
    void replace (ForwardIterator first, ForwardIterator last,
                  const T& old_value, const T& new_value);

// replace_if
template 
    void replace_if (ForwardIterator first, ForwardIterator last,
                     UnaryPredicate pred, const T& new_value );

// replace_copy
template 
    OutputIterator replace_copy (InputIterator first, InputIterator last,
                                 OutputIterator result,
                                 const T& old_value, const T& new_value);

// replace_copy_if
template 
    OutputIterator replace_copy_if (InputIterator first, InputIterator last,
                                    OutputIterator result, UnaryPredicate pred,
                                    const T& new_value);

fill
template 
    void fill (ForwardIterator first, ForwardIterator last, const T& val);
ゲナート
template 
    void generate (ForwardIterator first, ForwardIterator last, Generator gen);
remove
// remove
template 
    ForwardIterator remove (ForwardIterator first, ForwardIterator last, 
                            const T& val);

// remove_if
template 
    ForwardIterator remove_if (ForwardIterator first, ForwardIterator last,
                               UnaryPredicate pred);

// remove_copy
template 
    OutputIterator remove_copy (InputIterator first, InputIterator last,
                                OutputIterator result, const T& val);
unique
// equality 
template 
    ForwardIterator unique (ForwardIterator first, ForwardIterator last);

// predicate
template 
    ForwardIterator unique (ForwardIterator first, ForwardIterator last,
                            BinaryPredicate pred);
逆転セ
template 
    void reverse (BidirectionalIterator first, BidirectionalIterator last);
rotate
template 
    ForwardIterator rotate (ForwardIterator first, ForwardIterator middle,
                            ForwardIterator last);
ランドムshuffle
// generator by default 
template 
    void random_shuffle (RandomAccessIterator first, RandomAccessIterator last);

// specific generator
template 
    void random_shuffle (RandomAccessIterator first, RandomAccessIterator last,
                         RandomNumberGenerator&& gen);
パーティー
template 
    ForwardIterator partition (ForwardIterator first,
                               ForwardIterator last, UnaryPredicate pred);
並べ替え
  • 発泡体並べ替え
  • 挿入順序:直接挿入順序、ヒル順序
  • は、並べ替え(const)を選択します.並べ替え、積み上げ
  • は直接選択されます.
  • 快速並べ替え
  • 正規並べ替え(const)
  • バレルの並べ替え
  • 基数並べ替え(const)
  • カウント順序
  • メモリ分配器
    メモリ分配器はインターフェースを満たす必要があります.
  • グループtypedef:
  • allocator::value_type
    allocator::pointer
    allocator::const_pointer
    allocator::reference
    allocator::const_reference
    allocator::size_type
    allocator::difference_type
    
  • allocator:rebind:allocatorの埋め込みテンプレートは、otherメンバー
  • を定義する必要があります.
  • allocator:allocator():構造関数