[map] Return references from new iter_ref()

This commit is contained in:
Behdad Esfahbod 2022-06-03 01:11:22 -06:00
parent a7a688616a
commit 25f57230d5
1 changed files with 7 additions and 0 deletions

View File

@ -94,6 +94,7 @@ struct hb_hashmap_t
bool operator == (const K &o) { return hb_deref (key) == hb_deref (o); } bool operator == (const K &o) { return hb_deref (key) == hb_deref (o); }
bool operator == (const item_t &o) { return *this == o.key; } bool operator == (const item_t &o) { return *this == o.key; }
hb_pair_t<K, V> get_pair() const { return hb_pair_t<K, V> (key, value); } hb_pair_t<K, V> get_pair() const { return hb_pair_t<K, V> (key, value); }
hb_pair_t<const K &, const V &> get_pair_ref() const { return hb_pair_t<const K, const V &> (key, value); }
uint32_t total_hash () const uint32_t total_hash () const
{ return (hash * 31) + hb_hash (value); } { return (hash * 31) + hb_hash (value); }
@ -281,6 +282,12 @@ struct hb_hashmap_t
| hb_filter (&item_t::is_real) | hb_filter (&item_t::is_real)
| hb_map (&item_t::get_pair) | hb_map (&item_t::get_pair)
) )
auto iter_ref () const HB_AUTO_RETURN
(
+ hb_array (items, mask ? mask + 1 : 0)
| hb_filter (&item_t::is_real)
| hb_map (&item_t::get_pair)
)
auto keys () const HB_AUTO_RETURN auto keys () const HB_AUTO_RETURN
( (
+ hb_array (items, mask ? mask + 1 : 0) + hb_array (items, mask ? mask + 1 : 0)