std::unordered_set 是一个无序的集合,它不允许重复的元素。元素的数量可以使用 size() 方法来获取,例如:

std::unordered_setstd::string mySet; mySet.insert("apple"); mySet.insert("banana"); mySet.insert("orange");

int count = mySet.size(); 上述代码中,mySet 中的元素数量为 3,因为它包含了三个不同的字符串元素。

C++ std::unordered_set<std::string> 元素数量 - 获取集合大小

原文地址: https://www.cveoy.top/t/topic/qaGx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录