std::flat_set 在标头<flat_set>定义 template< classKey, classCompare=std::less<Key>, classKeyContainer=std::vector<Key> >classflat_set; (C++23 起) 平铺集合(flat set)是一种容器适配器,给出存储Key类型的唯一对象的有序集合的关联容器的功能。用键比较函数Compare来进行排序。
#include <algorithm>#include <iostream>#include <flat_set>intmain(){std::flat_set<int>alice{1,2,3};std::flat_set<int>bob{7,8,9,10};autoprint=[](constint&n){std::cout<<' '<<n;};// Print state before swapstd::cout<<"Alice:";std::for_each(alice.begin(), alice.end(), ...
{ std::flat_set data{3, 3, 4, 5, 5, 6, 6, 7, 2, 1, 0}; println("Original:\n", data); auto divisible_by_3 = [](auto const& x) { return (x % 3) == 0; }; const auto count = std::erase_if(data, divisible_by_3); println("Erase all items divisible by 3:\n"...
absl::flat_hash_set<constCandidate * > &IdentifierDatabase::GetCandidateSet( 117+ std::unordered_set<constCandidate * > &IdentifierDatabase::GetCandidateSet( 118118 conststd::string &filetype, 119119 conststd::string &filepath ) { 120120 ...
std::vector的内存结构 container-array 在遍历的过程中,通过将当前指针+pos来获取下一个节点的信息 内存布局是连续的 内存访问与CPU Cache container-cpu-cache CPU不会直接操作内存,当CPU需要加载内存中的数据时,CPU会把内存的数据以cache line为单位先加载到L1/L2/L3 cache,再加载到寄存器,再进行数据的计算 ...
flat_set::count flat_set::find flat_set::contains flat_set::equal_range flat_set::lower_bound flat_set::upper_bound Observers flat_set::key_comp flat_set::value_comp Non-member functions operator==operator<=> (C++23)(C++23) swap(std::flat_set) ...
From cppreference.com std::flat_set iterator find(constKey&key); (1)(since C++23) const_iterator find(constKey&key)const; (2)(since C++23) template<classK> iterator find(constK&x); (3)(since C++23) template<classK> const_iterator find(constK&x)const; ...
flat_set::key_comp flat_set::value_comp Non-member functions operator==operator<=> (C++23)(C++23) swap(std::flat_set) (C++23) erase_if(std::flat_set) (C++23) Helper classes uses_allocator<std::flat_set> (C++23) Tags sorted_uniquesorted_unique_t (C++23)(C++23) sorted_equivalent...
flat_set::equal_range flat_set::lower_bound flat_set::upper_bound Observers flat_set::key_comp flat_set::value_comp Non-member functions operator==operator<=> (C++23)(C++23) swap(std::flat_set) (C++23) erase_if(std::flat_set) (C++23) Helper classes uses_allocator<std::flat_set>...
std::flat_set Member types Member functions flat_set::flat_set flat_set::operator= Iterators flat_set::beginflat_set::cbegin flat_set::endflat_set::cend flat_set::rbeginflat_set::crbegin flat_set::rendflat_set::crend Capacity flat_set::size flat_set::max_size flat_set::empty Modifi...