Add sink support for hb_hashmap_t and a reverse call to hb_pair_t.
authorGarret Rieger <grieger@google.com>
Wed, 8 May 2019 23:31:52 +0000 (16:31 -0700)
committerGarret Rieger <grieger@google.com>
Thu, 9 May 2019 21:52:01 +0000 (14:52 -0700)
src/hb-algs.hh
src/hb-map.hh

index f211242..ca70755 100644 (file)
@@ -217,6 +217,11 @@ struct hb_pair_t
   hb_pair_t (T1 a, T2 b) : first (a), second (b) {}
   hb_pair_t (const pair_t& o) : first (o.first), second (o.second) {}
 
+  hb_pair_t<T1, T2> reverse () const
+  {
+    return hb_pair_t<T1, T2> (second, first);
+  }
+
   bool operator == (const pair_t& o) const { return first == o.first && second == o.second; }
 
   T1 first;
index 9dc1788..942a301 100644 (file)
@@ -231,6 +231,10 @@ struct hb_hashmap_t
     | hb_map (hb_ridentity)
   )
 
+  /* Sink interface. */
+  hb_hashmap_t<K, V, kINVALID, vINVALID>& operator << (const hb_pair_t<K, V>& v)
+  { set (v.first, v.second); return *this; }
+
   protected:
 
   unsigned int bucket_for (K key) const