[map] Add .values() iterator

This commit is contained in:
Behdad Esfahbod 2019-05-08 15:08:10 -07:00
parent 3c69505b3a
commit a304827184
2 changed files with 13 additions and 1 deletions

View File

@ -216,12 +216,16 @@ struct hb_hashmap_t
| 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)
)
auto values () const HB_AUTO_RETURN
(
+ iter()
| hb_map (&hb_pair_t<K, V>::second)
)
protected:

View File

@ -215,6 +215,14 @@ main (int argc, char **argv)
using map_key_t = decltype (*m.keys());
+ hb_iter (m.keys ())
| hb_filter ([] (map_key_t k) { return k < 42; })
| hb_drain
;
m.values ();
using map_value_t = decltype (*m.values());
+ hb_iter (m.values ())
| hb_filter ([] (map_value_t k) { return k < 42; })
| hb_drain
;
unsigned int temp1 = 10;