Skip to content

Commit

Permalink
flat_map : emptyとmax_sizeを追加 #1078
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed May 22, 2023
1 parent aaff7b5 commit 9430b41
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 4 deletions.
6 changes: 3 additions & 3 deletions reference/flat_map/flat_map.md
Expand Up @@ -47,10 +47,10 @@ namespace std {
### 領域
| 名前 | 説明 | 対応バージョン |
|---------------------------------|------------------------------------|-------|
| [`empty`](flat_map/empty.md.nolink) | コンテナが空であるかどうかを調べる | C++23 |
|------------------------------------|------------------------------------|-------|
| [`empty`](flat_map/empty.md) | コンテナが空であるかどうかを調べる | C++23 |
| [`size`](flat_map/size.md) | 要素数を取得する | C++23 |
| [`max_size`](flat_map/max_size.md.nolink) | 格納可能な最大の要素数を取得する | C++23 |
| [`max_size`](flat_map/max_size.md) | 格納可能な最大の要素数を取得する | C++23 |
### コンテナの変更
Expand Down
60 changes: 60 additions & 0 deletions reference/flat_map/flat_map/empty.md
@@ -0,0 +1,60 @@
# empty
* flat_map[meta header]
* std[meta namespace]
* flat_map[meta class]
* function[meta id-type]
* cpp23[meta cpp]

```cpp
[[nodiscard]] bool empty() const noexcept; // (1) C++23
```

## 概要
コンテナが空かどうかをテストする。
コンテナが空([`size()`](size.md) が 0)の場合に `true` を返す。

この関数はコンテナ内のコンテンツを変化させない。コンテンツをクリアするには [`clear()`](clear.md.nolink) メンバ関数を使用する。


## 戻り値
コンテナサイズが 0 のときに `true`, そうでないときに `false` を返す。


## 計算量
定数時間。


##
```cpp example
#include <iostream>
#include <flat_map>

int main ()
{
stdx::flat_map<int, char> fm;

std::cout << fm.empty() << std::endl;

fm.insert({42, 'a'});

std::cout << fm.empty() << std::endl;
}
```
* empty()[color ff0000]
* fm.insert[link insert.md.nolink]

### 出力
```
1
0
```

## バージョン
### 言語
- C++23

### 処理系
- [Clang](/implementation.md#clang): ??
- [GCC](/implementation.md#gcc): ??
- [Visual C++](/implementation.md#visual_cpp): ??

52 changes: 52 additions & 0 deletions reference/flat_map/flat_map/max_size.md
@@ -0,0 +1,52 @@
# max_size
* flat_map[meta header]
* std[meta namespace]
* flat_map[meta class]
* function[meta id-type]
* cpp23[meta cpp]

```cpp
size_type max_size() const noexcept; // (1) C++23
```

## 概要
コンテナが格納できる要素の最大数を返す。
これは、システムやライブラリ実装の制限のもとでコンテナが格納できる潜在的な最大サイズである。


## 戻り値
コンテナが自身のコンテンツとして保持できる要素の最大数。
メンバ型 `size_type` は符号なし整数型である。


## 計算量
定数時間。


##
```cpp example
#include <iostream>
#include <flat_map>

int main()
{
std::flat_map<char, int> fm;

std::cout << fm.max_size() << std::endl;
}
```
* max_size()[color ff0000]

### 出力例
```
178956970
```

## 言語バージョン
- C++23

### 処理系
- [Clang](/implementation.md#clang): ??
- [GCC](/implementation.md#gcc): ??
- [Visual C++](/implementation.md#visual_cpp): ??

2 changes: 1 addition & 1 deletion reference/flat_map/flat_map/size.md
Expand Up @@ -62,4 +62,4 @@ int main ()


## 関連項目
- [`empty()`](empty.md.nolink)
- [`empty()`](empty.md)

0 comments on commit 9430b41

Please sign in to comment.