diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 0ea884314..eaefc3bc6 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -449,6 +449,27 @@ struct UnsizedOffsetListOf : UnsizedOffsetArrayOf } }; +/* An array with sorted elements. Supports binary searching. */ +template +struct SortedUnsizedArrayOf : UnsizedArrayOf +{ + inline hb_sorted_array_t as_array (unsigned int len) + { return hb_sorted_array (this->arrayZ, len); } + inline hb_sorted_array_t as_array (unsigned int len) const + { return hb_sorted_array (this->arrayZ, len); } + + template + inline Type &bsearch (unsigned int len, const T &x) + { return *as_array (len).bsearch (x, &Crap (Type)); } + template + inline const Type &bsearch (unsigned int len, const T &x) const + { return *as_array (len).bsearch (x, &Null (Type)); } + template + inline bool bfind (unsigned int len, const T &x, unsigned int *i = nullptr) const + { return as_array (len).bfind (x, i); } +}; + + /* An array with a number of elements. */ template struct ArrayOf