アルゴリズム

アルゴリズム

STLのアルゴリズムは約80近くの関数が提供されている。ここでは高い頻度で使いそうなものを書き出しておく。

探索

指定した基準(条件)に合う要素を探す。
  • find/find_if
  • find_first_of
  • max_element
  • min_element
  • adjacent_find

ソート済み要素探索

ソート済み要素に対する探索。
  • binary_search
  • lower_bound
  • upper_bound
  • equal_range

範囲探索

探索条件が範囲(要素郡)となる探索。
  • equal
  • search
  • find_end
  • include
  • lexicographical_compare
  • mismatch

並べ替え

指定の基準で要素を並べ替える。
  • sort/stable_sort
  • partial_sort
  • nth_element
  • partition/stable_partition

並べ替え2

特定のルールで要素を並べ替える。
  • next_permutation/prev_permutation
  • random_shuffle
  • reverse/reverse_copy
  • rotate/rotate_copy

要素の削除

指定の基準で要素を削除する。コンテナのサイズは変わらない(末尾は不定値が入る)。
  • remove
  • uniq

走査

各要素に対し操作を行う。
  • count/count_if
  • accumulate
  • for_each
  • transform

集合演算

要素郡に対し,集合演算を行う。
  • set_difference
  • set_intersection
  • set_union
  • set_symmetric_difference

  • 最終更新:2009-05-17 22:47:09

このWIKIを編集するにはパスワード入力が必要です

認証パスワード