Maria GDK 5.0.0.850
Documentation of native code in develop branch
Loading...
Searching...
No Matches
STK::KeyView< Assoc > Class Template Reference

#include <StkKeyView.h>

Classes

struct  iterator
 

Public Types

using key_type = typename Assoc::key_type
 
using base_iter = typename Assoc::const_iterator
 

Public Member Functions

 KeyView (const Assoc &a)
 
iterator begin () const
 
iterator end () const
 
std::size_t size () const
 
bool empty () const
 

Detailed Description

template<class Assoc>
class STK::KeyView< Assoc >

KeyView - Return an iteratable "view" of the keys of an associative container without any copying.

Example:

class MyClass {
public:
std::map<std::string, int> items;
// Zero-allocation, zero-copy key view
auto keys() const noexcept { return STK::KeyView(items); }
};
...
MyClass c;
c.items["apple"] = 1;
c.items["banana"] = 2;
// Iterates "apple", "banana" in map order, with no allocations
for (const auto& k : c.keys()) {
// use k
}
Definition: StkKeyView.h:44
Template Parameters
AssocAssociative collection like std::map<K,V,...> or std::unordered_map<...>

The documentation for this class was generated from the following file: