C++ map
mapの使い方まとめ:
1.
第1種
:
Insert関数pairデータ挿入
.
mapStudent.insert(pair(1, "student_one"));
第2種
:
insert関数挿入value_typeデータ
mapStudent.insert(map::value_type (1, "student_one"));
第3種
:
配列方式データの挿入
mapStudent[1] =
"student_one";
mapStudent.insert(map::value_type (1, "student_one"));
mapStudent.insert(map::value_type (1, "student_two"));
上記の2つの文が実行された後、mapの1というキーワードに対応する値は「student_one」であり、2番目の文は有効ではありません.では、insert文が正常に挿入されたかどうかをどのように知るかについて、pairで挿入に成功したかどうかを得ることができます.手順は以下の通りです.
pair
1.
第1種
:
Insert関数pairデータ挿入
.
mapStudent.insert(pair
第2種
:
insert関数挿入value_typeデータ
mapStudent.insert(map
第3種
:
配列方式データの挿入
mapStudent[1] =
"student_one";
mapStudent.insert(map
mapStudent.insert(map
上記の2つの文が実行された後、mapの1というキーワードに対応する値は「student_one」であり、2番目の文は有効ではありません.では、insert文が正常に挿入されたかどうかをどのように知るかについて、pairで挿入に成功したかどうかを得ることができます.手順は以下の通りです.
pair