Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions reference/unordered_map/unordered_map/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,27 @@ void clear() noexcept;
投げない。


## 備考
Comment thread
akinomyoga marked this conversation as resolved.
Outdated
- `clear()` は バケット数([`bucket_count`](bucket_count.md)`()`)を縮小することを規格上は要求していない。
Comment thread
math-hiyoko marked this conversation as resolved.
Outdated
実装によっては `clear()` 後もバケット配列が維持され、動的メモリが残る場合がある。
- メモリを確実に解放したいときには以下のように操作を行う
```CPP
Comment thread
math-hiyoko marked this conversation as resolved.
Outdated
std::unordered_map<std::string, int> tmp;
s.swap(tmp);
```


## 計算量
本関数呼び出し前のコンテナの要素数([`size`](size.md)`()`)に比例

### 計算量に関する備考
- 多くの実装(GCC libstdc++, LLVM libc++ など)は
1. 全ての要素を破棄する
2. 全てのバケットを順に走査して各バケットを破棄

という手順を取るため、実行時間は概ね [`bucket_count`](bucket_count.md)`()` + [`size`](size.md)`()` に比例する傾向がある。
Comment thread
math-hiyoko marked this conversation as resolved.
Outdated
これは規格が定義する「計算量」(オブジェクトに対する操作の数)とは別物である。
Comment thread
faithandbrave marked this conversation as resolved.
Outdated
Comment thread
akinomyoga marked this conversation as resolved.
Outdated


## 例
```cpp example
Expand Down
18 changes: 18 additions & 0 deletions reference/unordered_map/unordered_multimap/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,27 @@ void clear() noexcept;
投げない。


## 備考
- `clear()` は バケット数([`bucket_count`](bucket_count.md)`()`)を縮小することを規格上は要求していない。
実装によっては `clear()` 後もバケット配列が維持され、動的メモリが残る場合がある。
- メモリを確実に解放したいときには以下のように操作を行う
```CPP
std::unordered_multimap<std::string, int> tmp;
s.swap(tmp);
```


## 計算量
本関数呼び出し前のコンテナの要素数([`size`](size.md)`()`)に比例

### 計算量に関する備考
- 多くの実装(GCC libstdc++, LLVM libc++ など)は
1. 全ての要素を破棄する
2. 全てのバケットを順に走査して各バケットを破棄

という手順を取るため、実行時間は概ね [`bucket_count`](bucket_count.md)`()` + [`size`](size.md)`()` に比例する傾向がある。
これは規格が定義する「計算量」(オブジェクトに対する操作の数)とは別物である。


## 例
```cpp example
Expand Down
18 changes: 18 additions & 0 deletions reference/unordered_set/unordered_multiset/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,27 @@ void clear() noexcept;
投げない。


## 備考
- `clear()` は バケット数([`bucket_count`](bucket_count.md)`()`)を縮小することを規格上は要求していない。
実装によっては `clear()` 後もバケット配列が維持され、動的メモリが残る場合がある。
- メモリを確実に解放したいときには以下のように操作を行う
```CPP
std::unordered_multiset<int> tmp;
s.swap(tmp);
```


## 計算量
本関数呼び出し前のコンテナの要素数([`size`](size.md)`()`)に比例

### 計算量に関する備考
- 多くの実装(GCC libstdc++, LLVM libc++ など)は
1. 全ての要素を破棄する
2. 全てのバケットを順に走査して各バケットを破棄

という手順を取るため、実行時間は概ね [`bucket_count`](bucket_count.md)`()` + [`size`](size.md)`()` に比例する傾向がある。
これは規格が定義する「計算量」(オブジェクトに対する操作の数)とは別物である。


## 例
```cpp example
Expand Down
18 changes: 18 additions & 0 deletions reference/unordered_set/unordered_set/clear.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,27 @@ void clear() noexcept;
投げない。


## 備考
- `clear()` は バケット数([`bucket_count`](bucket_count.md)`()`)を縮小することを規格上は要求していない。
実装によっては `clear()` 後もバケット配列が維持され、動的メモリが残る場合がある。
- メモリを確実に解放したいときには以下のように操作を行う
```CPP
std::unordered_set<int> tmp;
s.swap(tmp);
```


## 計算量
本関数呼び出し前のコンテナの要素数([`size`](size.md)`()`)に比例

### 計算量に関する備考
- 多くの実装(GCC libstdc++, LLVM libc++ など)は
1. 全ての要素を破棄する
2. 全てのバケットを順に走査して各バケットを破棄

という手順を取るため、実行時間は概ね [`bucket_count`](bucket_count.md)`()` + [`size`](size.md)`()` に比例する傾向がある。
これは規格が定義する「計算量」(オブジェクトに対する操作の数)とは別物である。


## 例
```cpp example
Expand Down