[map] Make .has() optionally return value
This commit is contained in:
parent
750d5af48e
commit
bad1606639
|
@ -181,7 +181,12 @@ struct hb_hashmap_t
|
||||||
static constexpr V SENTINEL = vINVALID;
|
static constexpr V SENTINEL = vINVALID;
|
||||||
typedef V value_t;
|
typedef V value_t;
|
||||||
value_t operator [] (K k) const { return get (k); }
|
value_t operator [] (K k) const { return get (k); }
|
||||||
bool has (K k) const { return (*this)[k] != SENTINEL; }
|
bool has (K k, V *vp = nullptr) const
|
||||||
|
{
|
||||||
|
V v = (*this)[k];
|
||||||
|
if (vp) *vp = v;
|
||||||
|
return v != SENTINEL;
|
||||||
|
}
|
||||||
/* Projection. */
|
/* Projection. */
|
||||||
V operator () (K k) const { return get (k); }
|
V operator () (K k) const { return get (k); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue