std::flat_multiset<Key,Compare,KeyContainer>::empty
來自 cppreference.com
< cpp | 容器 | flat multiset
bool empty() const noexcept; |
(C++23 起) | |
檢查底層容器是否沒有元素。等價於:return begin() == end();。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
如果底層容器為空,則為true,否則為false。
[編輯] 複雜度
常數時間。
[編輯] 示例
以下程式碼使用 empty
來檢查 std::flat_multiset<int> 是否包含任何元素
執行此程式碼
#include <iostream> #include <flat_set> int main() { std::flat_multiset<int> numbers; std::cout << std::boolalpha; std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n'; numbers.insert(42); numbers.insert(19937); std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n'; }
輸出
Initially, numbers.empty(): true After adding elements, numbers.empty(): false
[編輯] 參閱
返回元素數量 (public member function) | |
(C++17) |
檢查容器是否為空 (function template) |