std::set,multiset
- set,multiset
- インクルード
- 初期化(コンストラクタ)
- 要素アクセス(begin,end,rbegin,rend)
- サイズ確認(size,max_size,empty)
- 編集(insert,erase,clear,swap)
- マップの走査(find,count,lower_bound,upper_bound,equal_range)
- 比較関数(key_comp,value_comp)
set,multiset†
mapと同様の連想コンテナだが,キーと値を一緒に格納することが異なる.
値の一部をキーとする.multisetはキーの重複を許したバージョン.
インクルード†
#include <set>
初期化(コンストラクタ)†
explicit set(const Compare& comp = Compare(),
const Allocator& = Allocator());
template <class InputIterator>
set(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
set(const set<Key,Compare,Allocator>& x);
explicit multiset(const Compare& comp = Compare(),
const Allocator& = Allocator());
template <class InputIterator>
multiset(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
multiset(const multiset<Key,Compare,Allocator>& x);
要素アクセス(begin,end,rbegin,rend)†
サイズ確認(size,max_size,empty)†
編集(insert,erase,clear,swap)†
- insert(val) : 要素を挿入する.
pair<iterator,bool> insert(const value_type& x);
iterator insert(iterator position, const value_type& x);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
- erase(iter) : 要素を削除する.
void erase(iterator position); // イテレータで示された位置の要素削除
size_type erase(const key_type& k); // キーがxである要素を削除
void erase(iterator first, iterator last); // イテレータで示された範囲の要素削除
- clear() : コンテナのクリア.全要素を削除する.
void clear();
- swap() : 2つのコンテナのスワップ.
void swap(set<Key,Compare,Allocator>& st);
マップの走査(find,count,lower_bound,upper_bound,equal_range)†
- find(k) : キーがxである要素を検索してそのイテレータを返す.見つからなければ末尾のイテレータ(end())が返される.
iterator find(const key_type& k) const;
- count(k) : マップ内のキーがxである要素の数を返す(mapでは0か1,multimapでは数)
size_type count(cont key_type& k) const;
- lower_bound(k) : キーがx以上である最初の要素を示すイテレータを返す
iterator lower_bound(const key_type& k) const;
- upper_bound(k) : キーがxより大きい最初の要素を示すイテレータを返す
iterator upper_bound(const key_type& k) const;
- equal_range(k) : キーがxである要素の範囲(イテレータのpair)を返す(mapでは1要素のみ)
pair<iterator,iterator> equal_range(const key_type& k) const;
比較関数(key_comp,value_comp)†
|