[map] Add hb_map_keys() and hb_map_values()

This commit is contained in:
Behdad Esfahbod 2023-01-04 17:12:08 -07:00
parent 07f2d8d538
commit 35f46e74d1
7 changed files with 60 additions and 1 deletions

View File

@ -548,6 +548,8 @@ hb_map_is_equal
hb_map_hash hb_map_hash
hb_map_update hb_map_update
hb_map_next hb_map_next
hb_map_keys
hb_map_values
HB_MAP_VALUE_INVALID HB_MAP_VALUE_INVALID
hb_map_t hb_map_t
</SECTION> </SECTION>

View File

@ -34,7 +34,6 @@
#include "hb-dispatch.hh" #include "hb-dispatch.hh"
#include "hb-sanitize.hh" #include "hb-sanitize.hh"
#include "hb-serialize.hh"
/* /*

View File

@ -384,3 +384,35 @@ hb_map_next (const hb_map_t *map,
{ {
return map->next (idx, key, value); return map->next (idx, key, value);
} }
/**
* hb_map_keys:
* @map: A map
* @keys: A set
*
* Add the keys of @map to @keys.
*
* Since: REPLACEME
**/
void
hb_map_keys (const hb_map_t *map,
hb_set_t *keys)
{
map->keys (*keys);
}
/**
* hb_map_values:
* @map: A map
* @values: A set
*
* Add the values of @map to @values.
*
* Since: REPLACEME
**/
void
hb_map_values (const hb_map_t *map,
hb_set_t *values)
{
map->values (*values);
}

View File

@ -129,6 +129,14 @@ hb_map_next (const hb_map_t *map,
hb_codepoint_t *key, hb_codepoint_t *key,
hb_codepoint_t *value); hb_codepoint_t *value);
HB_EXTERN void
hb_map_keys (const hb_map_t *map,
hb_set_t *keys);
HB_EXTERN void
hb_map_values (const hb_map_t *map,
hb_set_t *values);
HB_END_DECLS HB_END_DECLS
#endif /* HB_MAP_H */ #endif /* HB_MAP_H */

View File

@ -29,6 +29,8 @@
#include "hb.hh" #include "hb.hh"
#include "hb-set.hh"
/* /*
* hb_hashmap_t * hb_hashmap_t
@ -315,6 +317,16 @@ struct hb_hashmap_t
hb_copy (other, *this); hb_copy (other, *this);
} }
void keys (hb_set_t &keys_) const
{
hb_copy (keys() , keys_);
}
void values (hb_set_t &values_) const
{
hb_copy (values() , values_);
}
/* /*
* Iterator * Iterator
*/ */

View File

@ -170,6 +170,11 @@ struct hb_set_t : hb_sparseset_t<hb_bit_set_invertible_t>
template <typename Iterable, template <typename Iterable,
hb_requires (hb_is_iterable (Iterable))> hb_requires (hb_is_iterable (Iterable))>
hb_set_t (const Iterable &o) : sparseset (o) {} hb_set_t (const Iterable &o) : sparseset (o) {}
hb_set_t& operator << (hb_codepoint_t v)
{ sparseset::operator<< (v); return *this; }
hb_set_t& operator << (const hb_pair_t<hb_codepoint_t, hb_codepoint_t>& range)
{ sparseset::operator<< (range); return *this; }
}; };
static_assert (hb_set_t::INVALID == HB_SET_VALUE_INVALID, ""); static_assert (hb_set_t::INVALID == HB_SET_VALUE_INVALID, "");

View File

@ -33,6 +33,7 @@
#include "hb-subset.h" #include "hb-subset.h"
#include "hb-machinery.hh" #include "hb-machinery.hh"
#include "hb-serialize.hh"
#include "hb-subset-input.hh" #include "hb-subset-input.hh"
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"