From 959bb58bdda8e78690789441e07cf22a99113c53 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 26 Dec 2018 18:54:15 -0500 Subject: [PATCH] [vector] Add iterator --- src/hb-vector.hh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 587a85fb8..5bea558e3 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -94,6 +94,14 @@ struct hb_vector_t hb_array_t as_array () const { return hb_array (arrayZ(), length); } + /* Iterator. */ + typedef hb_array_t const_iter_t; + const_iter_t const_iter () const { return as_array (); } + operator const_iter_t () const { return const_iter (); } + typedef hb_array_t iter_t; + iter_t iter () { return as_array (); } + operator iter_t () { return iter (); } + hb_array_t sub_array (unsigned int start_offset, unsigned int count) const { return as_array ().sub_array (start_offset, count);} hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const @@ -119,8 +127,6 @@ struct hb_vector_t template explicit_operator T * () { return arrayZ(); } template explicit_operator const T * () const { return arrayZ(); } - operator hb_array_t () { return as_array (); } - operator hb_array_t () const { return as_array (); } Type * operator + (unsigned int i) { return arrayZ() + i; } const Type * operator + (unsigned int i) const { return arrayZ() + i; }