より詳しい解説ノートです。

基本的な コンテナ/反復子/関数オブジェクト/アルゴリズム に的を
絞って詳しく解説しています。

stack/queue/priority_queue/bitset/string/rope/valarray/complex については、
また後日、STLプロフェッサー・ノートの方で詳しく解説します。

初歩的な説明は全部とっぱらっていますが、
それでもやっぱり見にくいです。

それから、SGI社のSTLについてはcompose辺りの説明が若干違います。


〔STL-コンテナ〕

■コンテナ共通の項目

■vector

■vector<bool>

■deque


 
// deque : #include <deque>
namespace std {
template<class T,class Allocator = allocator<T> >
class deque ;
}

■list

■set/multiset


 
// set/multiset : #include <set>
namespace std {
template < class T,
class Compare = less<T>,
class Allocator = allocator<T> >
class set ;
template < class T,
class Compare = less<T>,
class Allocator = allocator<T> >
class multiset ;
}
※ Compare(elem1,elem2) に指定される演算の戻り値の必要条件について
  1. Compare(x,y) が真ならば、Compare(y,x) は偽になる。
  2. Compare(x,y) が真かつ、Compare(y,z) が真ならば、Compare(x,z) は真になる。
  3. Compare(x,x) は必ず偽になる。
  • set/multiset の特徴

  •  
    1. set/multiset は、比較準拠関数オブジェクトでソートした平衡二分木として実装される。 setは、要素の重複を許さない一方で multisetは、要素の重複を許す。
    2. 要素は、予めソート済の二分木で搭載されているため、値を指定した要素位置の探索が非常に高速である。
    3. 登録した要素の値を変更する行為は、ソート準拠に反するためサポートされない。
    4. 要素の順序は、不定形であるため、要素を直接アクセスするメソッドは利用できない。

    ■map/multimap

     
    // map/multimap : #include <map>
    namespace std {
    template < class Key, class T,
    class Compare = less<Key>,
    class Allocator = allocator<pair<const Key,T> > >
    class map ;
    template < class Key, class T,
    class Compare = less<Key>,
    class Allocator = allocator<pair<const Key,T> > >
    class multimap ;
    }
    ※ Compare(elem1,elem2) に指定される演算の戻り値の必要条件について
    1. Compare(x,y) が真ならば、Compare(y,x) は偽になる。
    2. Compare(x,y) が真かつ、Compare(y,z) が真ならば、Compare(x,z) は真になる。
    3. Compare(x,x) は必ず偽になる。
  • map/multimap の特徴

  •  
    1. map/multimap は、キーを比較準拠関数オブジェクトでソートした平衡二分木として実装される。 各々の要素は、キーと値のペアで組み合わせられる。 mapは、キーの重複を許さない一方で multimapは、キーの重複を許す。
    2. 登録したキーの値を変更する行為は、ソート準拠に反するためサポートされない。(値は変更可能)
    3. 要素の順序は、不定形であるため、要素自体を直接アクセスするメソッドは利用できない。 一方で c[key] = value のようにキーをターゲットに値を直接変更することが出来る。

    〔STL-反復子〕

    ■反復子の種類

    .

    ◆入力反復子

     入力反復子は、要素を読み取りながら進む反復子で、読み進める度にデータを外部インターフェイスなどの入力装置から拾ってくる目的で実装される。 この反復子の特徴は、データを読み進めることしかできずに全く書き込めない所にある。 また、一度読み取ったデータを再度読み取ることは出来ない。
    入力反復子の演算
    *iter
    実際の要素に対して読み取りアクセスを提供する。
    iter->member
    要素のメンバにアクセスする。
    ++iter
    1ステップ前進する。(新しい位置を返す)
    iter++
    1ステップ前進する。(前の位置を返す)
    iter1 == iter2
    2つの反復子が同じ位置かどうか。
    iter1 != iter2
    2つの反復子の位置が異なっているかどうか。
    TYPE(iter)
    反復子をコピーする。(コピーコンストラクタ)
     この反復子は、種類によっては、データを読み込む(*iterでアクセスする)と、反復子は自動で次の要素を指し示すことがある。
    .

    ◆出力反復子

     出力反復子は、要素を書き込みながら進む反復子で、書き進める度にデータを外部インターフェイスなどの出力装置に排出する目的で実装される。 この反復子の特徴は、出力先の終端を確かめるすべがなく、書き込み専用であるため要素を比較するための演算子が存在しない所にある。 また、一度書き込んだデータは戻って上書きすることができない。 
    出力反復子の演算
    *iter = value
    反復子の参照先にvalue要素を書き込む。
    ++iter
    1ステップ前進する。(新しい位置を返す)
    iter++
    1ステップ前進する。(前の位置を返す)
    TYPE(iter)
    反復子をコピーする。(コピーコンストラクタ)
     この反復子は、データが正常に書き込めたかどうかを確かめるすべを持たない。 また、データを書き込むと、反復子は自動で次の要素を指し示す。
    .

    ◆前方反復子

    前方反復子は、入力反復子と出力反復子の両方の機能を持ち合わせる反復子である。 入力反復子や出力反復子とは違い、同じ要素のデータを巻き戻して何度も参照することが出来る。
    .
    .

    ◆ランダムアクセス反復子

     ランダムアクセス反復子は、双方向反復子にランダムアクセス機能を追加したものである。 したがって、反復子のオフセットを考慮に入れた計算や比較が可能となる。
    双方向反復子に追加されるランダムアクセス反復子の演算
    iter[i]
    インデックスが i である要素にアクセスする。
    iter += n
    要素 n 個分だけ前進する。(nが負であれば後退する)
    iter -= n
    要素 n 個分だけ後退する。(nが正であれば前進する)
    n + iter
    n 個先の要素を示す反復子を返す。
    iter - n
    n 個前の要素を示す反復子を返す。
    iter1 - iter2
    iter1 と iter2 の差を返す。
    iter1 < iter2
    iter1 が iter2 より前にあるかどうかを返す。
    iter1 > iter2
    iter1 が iter2 より後にあるかどうかを返す。
    iter1 <= iter2
    iter1 が iter2 と同じ位置か前にあるかどうかを返す。
    iter1 >= iter2
    iter1 が iter2 と同じ位置か後にあるかどうかを返す。

     

    ■反復子の補助関数

    ◆advance()による反復子の移動操作

    // advance() : #include <iterator>
    namespace std {
    void advance( InputIterator& pos, Dist n ) ;
    }
     advance() 関数は、pos で指定された反復子の位置を n だけインクリメントさせる。 反復子が双方向モードをサポートしている場合、n は負でも構わない。 また、 advance() 関数は、ランダムアクセス反復子だけでなく、 ++演算子をサポートする全ての反復子で利用することができる。
    .

    ◆distance()による反復子の差の計算

    // distance() : #include <iterator>
    namespace std {
    Dist distance( InputIterator pos1, InputIterator pos2 ) ;
    }
     distance() 関数は、2つの反復子の差を返す。 この関数の使用時は、次の鉄則に従わなければならない。
    .

    ◆iter_swap()による反復子の値の交換

    // iter_swap() : #include <algorithm>
    namespace std {
    void iter_swap( InputIterator pos1, InputIterator pos2 ) ;
    }
     iter_swap() 関数は、2つの反復子が指し示している『要素』を入れ替える。 要素の型は、代入が可能であれば一致していなくても構わない。

    ■反復子アダプタ

    ◆逆反復子

     逆反復子とは、通常の反復子のインクリメント/デクリメントの演算を逆転して再定義したアダプタである。 逆反復子を得るには、各々のコンテナにある rbegin()/rend() メソッドを呼んで取得する。  また、通常の反復子を逆反復子に変換する場合は、reverse_iterator タイプ指定子を利用する。
    container<T>::reverse_iterator rpos( pos ) ;
     この変換を行った場合、rpos反復子の位置は、pos-1の位置に無条件に還元される。 これは、半開きの区間を反転するために起こるものと解釈される。 つまり、begin() は rend()、 end() は  rbegin() に還元されるために起こる。
     また、逆反復子を通常の反復子に戻すには、逆反復子付属のメソッドbase()を呼べばよい。
    pos = rpos.base() ;
     この反復子の位置もまた posは、rpos-1の位置に還元される。
    .

    ◆挿入反復子

     この反復子の特徴は、値の代入をトリガーに挿入ポイントをインクリメントするところにある。 この反復子に++演算子を利用するとその処理は、完全に無視される特性も持ち合わせる。
     

    ■反復子の特性

     
     反復子は、その特性を種別するために各々のタグを提供している。 この型指定子は、iterator_traits の iterator_category として利用される。
     
    // XXXXX_iterator_tag : #include <iterator>
    namespace std {
    struct output_iterator_tag {
    };
    struct input_iterator_tag {
    };
    struct forward_iterator_tag 
    : public input_iterator_tag {
    };
    struct bidirectional_iterator_tag
    : public forward_iterator_tag {
    };
    struct random_accesss_iterator_tag
    : public bidirectional_iterator_tag {
    };
    }
    .
     反復子の iterator_category() を利用すると 反復子の種類による場合分け処理を行うことが出来る。
     
    template <class Iterator>
    //双方向反復子用
    template <class BiIterator>
    void MultiFunc(BiIterator beg, BiIterator end
    ,std::bidirectional_iterator_tag)
    {
      ・・・
    }
    //ランダムアクセス反復子用
    template <class RaIterator>
    void MultiFunc(RaIterator beg, RaIterator end
    ,std::random_access_iterator_tag)
    {
      ・・・
    }
    //自動判別(本体)
    template <class Iterator>
    void MultiFunc(Iterator beg, Iterator end)
    {
    MultiFunc(beg,end
    ,iterator_traits<Iterator>::iterator_category()) ;
    }
    .
     この構造体を継承することによって、反復子に必要な iterator_traits 定義に関する型情報をオリジナルなものにアレンジ出来る仕組みになっている。
     
    //継承例
    template <class Container>
    class MyIterator
    : public std::iterator < std::output_iterator_tag,
    void, void, void, void > {
    protected:
    Container& container ;
    public:
    explict MyIterator(Container c) : container(c) {
    ・・・
    }
    MyIterator<Container>&
    operator = (const typename Container::value_type& value) {
    container.insert(value);
    return *this ;
    }
    MyIterator<Container>& operator* () {
    return *this ;
    }
    MyIterator<Container>& operator++ () { // ++p
    return *this ;
    }
    MyIterator<Container>& operator++ (int) { // p++
    return *this ;
    }
    }

    〔STL-関数オブジェクト〕

    ■事前定義の関数オブジェクト

     STLには、数多くの事前定義関数オブジェクトをサポートしている。 これらは、要素同士をパラーメータに受け渡す演算で利用される。 関数オブジェクトは、スマートオブジェクトであるため、コンストラクタ()が付加している。 これらのオブジェクトは、ヘッダファイル <functional> で定義されている。 
     
    事前定義の関数オブジェクト
    negate<type>()(param)
    - param
    plus<type>()(param1,param2)
    param1 + param2
    minus<type>()(param1,param2)
    param1 - param2
    multiplies<type>()(param1,param2)
    param1 * param2
    divides<type>()(param1,param2)
    param1 / param2
    modulus<type>()(param1,param2)
    param1 % param2
    equal_to<type>()(param1,param2)
    param1 == param2
    not_equal_to<type>()(param1,param2)
    param1 != param2
    less<type>()(param1,param2)
    param1 < param2
    greater<type>()(param1,param2)
    param1 > param2
    less_equal<type>()(param1,param2)
    param1 <= param2
    greater_equal<type>()(param1,param2)
    param1 >= param2
    logical_not<type>()(param1,param2)
    ! param
    logical_and<type>()(param1,param2)
    param1 && param2
    logical_or<type>()(param1,param2)
    param1 || param2

    ■関数アダプタ

     関数アダプタは、関数オブジェクト と 関数オブジェクト/値 を組み合わせて作る変換用のファンクタである。 これらのオブジェクトは、ヘッダファイル <functional> で定義されている。
     
    事前定義の関数アダプタ
    bind1st(op,value)(param)
    op(value,param)
    bind2nd(op,value)(param)
    op(param,value)
    not1(op)(param)
    !op(param)
    not2(op)(param1,param2)
    !op(param1,param2)
     

    ■メンバ関数のための関数アダプタ

      パラメタのクラスメンバを呼び出したい場合には、下記の2つの関数アダプタを利用する。
     
    メンバ関数のための関数アダプタ
    mem_fun_ref(op)(param[,value])
    op() を paramのオブジェクトメンバ関数として呼び出す。
    要するに、param.op( [value] ) を実行する。
    mem_fun(op)(param[,value])
    op() を (*param)のオブジェクトメンバ関数として呼び出す。
    要するに、param->op( [value] ) を実行する。

     op には、下記のようにパラメータを渡す。

    for_each( coll.begin(), coll.end(), mem_fun_ref(&Class::Method) )
    for_each( coll.begin(), coll.end(), mem_fun(&Class::Method) )
    for_each( coll.begin(), coll.end() // value オプションをバインドする例
    , bind2nd(mem_fun_ref(&Class::Method),value) )
    ※ coll の要素は、 Class から派生したものであることが条件。
     

    ■通常関数のための関数アダプタ

      通常の関数は、関数オブジェクトと違い、関数アダプタに合致した型情報を持っていない。 関数アダプタの型として渡す場合に問題が生じる。 このような通常の関数を関数オブジェクト化するための機能が ptr_fun である。
     
    メンバ関数のための関数アダプタ
    ptr_fun(op)(param[, param2])
    (*op)( param[ , param2] ) を実行する。

     op には、下記のようにパラメータを渡す。

    find_if( coll.begin(), coll.end(), not1(bind2nd(ptr_fun(strcmp),"名前")) )
     // 上記は、 coll の要素が char*型 であり、"名前"と一致する反復子を返す場合の例

    ■関数オブジェクトの自作

     関数アダプタに合致した関数オブジェクトを自作するには、 ヘッダファイル functional に定義されている unuary_function/binary_funciton の型定義情報を派生して利用する。
     
    // unuary_function / binary_function : #include <functional>
    template <class Arg,class Result>
    struct unary_function {
    typedef Arg argument_type ;
    typedef Result result_type ;
    } ;
    template <class Arg1,class Arg2,class Result>
    struct binary_function {
    typedef Arg1 first_argument_type ;
    typedef Arg2 second_argument_type ;
    typedef Result result_type ;
    } ;

     上記の型定義情報を作成して自作関数オブジェクトを作成すると、関数アダプタに渡しても問題のないオブジェクトを作成できる。
     
    #include <functional>
    template <class T>
    struct multiplies_n : public std::binary_function<T,int,T>
    {
    T operator() (T value, int n) const {
    T result = T(1) ;
    while(n--) {
    result *= value ;
    }
    return result ;
    }
    }

    ■関数オブジェクトの合成アダプタ

      STLは、通常の関数アダプタの他、関数オブジェクト同士を合成するアダプタも提供する。
     
    関数オブジェクトを合成するアダプタ
    compose_f_gx(f,g)(elem)
    f(g(elem)) に展開する。
    compose_f_gxy(f,g)(elem1,elem2)
    f(g(elem1,elem2)) に展開する。
    compose_f_gx_hx(f,g,h)(elem)
    f(g(elem),h(elem)) に展開する。
    compose_f_gx_hy(f,g,h)(elem1,elem2)
    f(g(elem1),h(elem2)) に展開する。

    〔STL-アルゴリズム〕

    #include <algorithm>

    ■for_each()アルゴリズム

    UnaryProc
    for_each (InputIterator beg, InputIterator end, UnaryProc op)
  • [beg,end) という範囲の各要素について、op(elem) を実行する。
  • 内部で変更された op のコピーの返す。
  • op に &演算子で要素の引数を指定した場合、op は要素を変更できる。
  • op の戻り値は無視される。
  • ■要素のカウント

    difference_type

    ■最小と最大の要素検出

    InputIterator

    ■要素の検索

    InputIterator

    ■連続する要素の検索

    InputIterator

    ■範囲に一致する要素の検索

    ForwardIterator

    ■最終範囲に一致する要素の検索

    ForwardIterator

    ■候補を指定した要素の検索

    ForwardIterator

    ■隣接する要素の検索

    ForwardIterator

    ■等価性のチェック

    bool

    ■異なる最初の要素の検索

    pair<InputIterator1,InputIterator2>

    ■辞書順位の比較

    bool

    ■要素のコピー

    OutputIterator
    copy (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg)
    BidirectionalIterator2

    ■要素の変換と結合

    OutputIterator
    transform (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg, UnaryFunc op)

    ■要素の交換

    ForwardIterator2
    swap_ranges (ForwardIterator1 beg1, ForwardIterator1 end1,
    ForwardIterator2 beg2)

    ■単一の値で要素を埋め尽くす

    void
    fill (ForwardIterator1 beg, ForwardIterator1 end, const T& newValue)
    fill_n (OutputIterator beg, Size num, const T& newValue)

    ■値を生成して要素を埋め尽くす

    void
    generate (ForwardIterator1 beg, ForwardIterator1 end, Func op)
    generate_n (OutputIterator beg, Size num, Func op)

    ■要素の検索置換

    void
    replace (ForwardIterator beg, ForwardIterator end,
    const T& searchValue, const T& replaceValue)
    replace_if (ForwardIterator beg, ForwardIterator end,
    UnaryPredicate op, const T& replaceValue)

    ■要素のコピーと検索置換

    OutputIterator
    replace_copy (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg,
    const T& searchValue, const T& replaceValue)
    replace_copy_if (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg,
    UnaryPredicate op, const T& replaceValue)

    ■要素の削除

    ForwardIterator
    remove (ForwardIterator beg, ForwardIterator end,
    const T& value)
    remove_if (ForwardIterator beg, ForwardIterator end,
    UnaryPredicate op)

    ■要素のコピーと削除

    OutputIterator
    remove_copy (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg, const T& value)
    remove_copy_if (InputIterator sourceBeg, InputIterator sourceEnd,
    OutputIterator destBeg, UnaryPredicate op)

    ■隣接の重複した要素の削除

    ForwardIterator
    unique (ForwardIterator beg, ForwardIterator end)
    unique (ForwardIterator beg, ForwardIterator end, BinaryPredicate op)
     

    ■コピーと隣接の重複した要素の削除

    OutputIterator
    unique_copy (InputIterator beg, InputIterator end,
    OutputIterator destBeg)
    unique_copy (InputIterator beg, InputIterator end,
    OutputIterator destBeg, BinaryPredicate op)

    ■要素順序の逆転

    void
    reverse (BidirectionalIterator beg, BidirectionalIterator end)
    OutputIterator
    reverse_copy (InputIterator beg, InputIterator end,
    OutputIterator destBeg, BinaryPredicate op)

    ■要素順序の回転

    void
    rotate (ForwardIterator beg, ForwardIterator newBeg, ForwardIterator end)

    ■コピーと要素順序の回転

    OutputIterator
    rotate_copy (ForwardIterator sourceBeg, ForwardIterator newBeg,
     ForwardIterator sourceEnd, OutputIerator destBeg)

    ■要素順序のステップソート

    bool
    next_permutation (BidirectionalIterator beg, BidirectionalIterator end)
    prev_permutation (BidirectionalIterator beg, BidirectionalIterator end)

    ■要素順序のシャッフル

    bool
    random_shuffle (RandomAccessIterator beg, RandomAccessIterator end)
    random_shuffle (RandomAccessIterator beg, RandomAccessIterator end,
    RandomFunc& op)

    ■要素全体の二分割

    BidirectionalIterator
    partition (BidirectionalIterator beg, BidirectionalIterator end,
    UnaryPredicate op)
    stable_partition (BidirectionalIterator beg, BidirectionalIterator end,
    UnaryPredicate op)

    ■要素全体のソート

    void
    sort (RandomAccessIterator beg, RandomAccessIterator end)
    sort (RandomAccessIterator beg, RandomAccessIterator end,
    BinaryPredicate op)
    stable_sort (RandomAccessIterator beg, RandomAccessIterator end)
    stable_sort (RandomAccessIterator beg, RandomAccessIterator end,
    BinaryPredicate op)

    ■要素の部分ソート

    void
    partial_sort (RandomAccessIterator beg, RandomAccessIterator sortEnd,
    RandomAccessIterator end)
    partial_sort (RandomAccessIterator beg, RandomAccessIterator sortEnd,
    RandomAccessIterator end, BinaryPredicate op)

    ■要素の部分ソートによる複写

    RandomAccessIterator
    partial_sort_copy (InputIterator sourceBeg, InputIterator sourceEnd,
    RandomAccessIterator destBeg,
    RandomAccessIterator destEnd)
    partial_sort_copy (InputIterator sourceBeg, InputIterator sourceEnd,
    RandomAccessIterator destBeg,
    RandomAccessIterator destEnd,
    BinaryPredicate op)

    ■n番目の要素を基準とした要素の二分割

    void
    nth_element (RandomAccessIterator beg, RandomAccessIterator nth,
    RandomAccessIterator end)
    nth_element (RandomAccessIterator beg, RandomAccessIterator nth,
    RandomAccessIterator end, BinaryPredicate op)

    ■コンテナのヒープソート

     ランダムアクセス反復子を利用するコンテナ(vector/deque)の要素を仮想的な二分木に整列し直すアルゴリズムをヒープソートという。 ヒープソートを行った要素は仮想的な二分木に展開されているため、要素を一つ追加するごとに最小のステップで整合化できるところに特徴がある。

     たとえば、次のような整数順列をヒープソートするとする。

    7 18 9 18 25 19 22
     上記の整数順列は、make_heap() を呼び出して整列させると以下のような形になる。
    25 18 22 7 9 19 18
     一見、何が行われたかわけがわからないが、この二分木構造は、以下のような形を表している。
     つまり、最上を頂点としてディスプレイの走査線のように木構造を構築している。
     この変換された整数順列に対して、sort_heap() を呼び出すと以下のようにソートされた順列に展開することが出来る。
    7 9 18 18 19 22 25

    void

    void

    void

    void

    ■予めソートされた区間の要素一つの存在可否

    bool
    binary_search (ForwardIterator beg, ForwardIterator end, const T& Value)
    binary_search (ForwardIterator beg, ForwardIterator end, const T& Value,
    BinaryPredicate op)

    ■予めソートされた区間の複数要素の存在可否

    bool
    includes (InputIterator1 beg, InputIterator1 end,
    InputIterator2 searchBeg, InputIterator2 searchEnd )
    includes (InputIterator1 beg, InputIterator1 end,
    InputIterator2 searchBeg, InputIterator2 searchEnd,
    BinaryPredicate op)

    ■予めソートされた区間の最初または最後の要素位置の検索

    ForwardIterator
    lower_bound (ForwardIterator beg, ForwardIterator end, const T& value)
    lower_bound (ForwardIterator beg, ForwardIterator end, const T& value,
    BinrayPredicate op)
    upper_bound (ForwardIterator beg, ForwardIterator end, const T& value)
    upper_bound (ForwardIterator beg, ForwardIterator end, const T& value,
    BinrayPredicate op)

    ■予めソートされた区間の要素範囲の検索

    pair<ForwardIterator, ForwardIterator>
    equal_range (ForwardIterator beg, ForwardIterator end, const T& value)
    equal_range (ForwardIterator beg, ForwardIterator end, const T& value,
    BinrayPredicate op)

    ■予めソートされた区間の要素範囲の結合

    OutputIterator
    merge (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg)
    merge (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg, BinrayPredicate op)

    ■予めソートされた区間の要素範囲の和

    OutputIterator
    set_union (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg)
    set_union (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg, BinrayPredicate op)

    ■予めソートされた区間の要素範囲の交差

    OutputIterator
    set_intersection (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg)
    set_intersection (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg, BinrayPredicate op)

    ■予めソートされた区間の要素範囲の差

    OutputIterator
    set_difference (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg)
    set_difference (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg, BinrayPredicate op)

    ■予めソートされた区間の要素範囲の差(2)

    OutputIterator
    set_symmetric_difference (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg)
    set_symmetric_difference (InputIterator source1Beg, InputIterator source1End,
    InputIterator source2Beg, InputIterator source2End,
    OutputIterator destBeg, BinrayPredicate op)

    ■予めソートされた区間の隣接区間結合

    void
    inplace_merge (BidirectionalIterator beg1,
     BidirectionalIterator end1beg2,
     BidirectionalIterator end2)
    inplace_merge (BidirectionalIterator beg1,
     BidirectionalIterator end1beg2,
     BidirectionalIterator end2, BinrayPredicate op)

    ■コンテナ要素の合計

    T
    accumulate (InputIterator beg, InputIterator end, T initValue)
    accumulate (InputIterator beg, InputIterator end, T initValue, BinrayFunc op)

    ■コンテナ要素同士の内積

    T
    inner_product (InputIterator beg1, InputIterator end1,
    InputIterator beg2, InputIterator end2, T initValue)
    inner_product (InputIterator beg1, InputIterator end1,
    InputIterator beg2, InputIterator end2, T initValue,
    BinrayFunc op1, BinrayFunc op2)

    ■コンテナ要素の各部分合計

    OutputIterator
    partial_sum (InputIterator sourceBeg, InputIterator sourceEnd,
     OutputIterator destBeg)
    partial_sum (InputIterator sourceBeg, InputIterator sourceEnd,
     OutputIterator destBeg, BinrayFunc op)

    ■コンテナ要素の絶対値を相対値へ変換

    OutputIterator
    adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
     OutputIterator destBeg)
    adjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd,
     OutputIterator destBeg, BinrayFunc op)