[map] add keys()

This commit is contained in:
rsheeter authored and Behdad Esfahbod committed 2019-05-08 15:08:33 -07:00
1 parent ba60512813
commit 492af0f1bf
2 files changed
+12 -1

No files matched your search

+8 -1
View File
@@ -212,11 +212,18 @@ struct hb_hashmap_t
*/
auto iter() const HB_AUTO_RETURN
(
+ hb_array_t<item_t> (items, mask + 1)
+ hb_array (items, mask + 1)
| hb_filter (&item_t::is_real)
| hb_map (&item_t::get_pair)
)
auto keys() const HB_AUTO_RETURN
(
+ iter()
| hb_map (&hb_pair_t<K, V>::first)
)
// | hb_map ([&] (item_t i) { return i.key; })
protected:
unsigned int bucket_for (K key) const
+4
View File
@@ -210,6 +210,10 @@ main (int argc, char **argv)
+ hb_iter (m)
| hb_map ([] (map_pair_t p) { return p.first * p.second; });
using map_key_t = decltype (*m.keys());
+ hb_iter (m.keys ())
| hb_filter ([] (map_key_t k) { return k < 42; });
unsigned int temp1 = 10;
unsigned int temp2 = 0;
hb_map_t *result =