[arrays] Start moving Supplier<> to hb_array_t<>
This commit is contained in:
parent
1e2c98126e
commit
507cac4943
|
@ -642,45 +642,36 @@ struct hb_serialize_context_t
|
|||
*/
|
||||
|
||||
template <typename Type>
|
||||
struct Supplier
|
||||
struct Supplier : hb_array_t<const Type>
|
||||
{
|
||||
Supplier (const Type *array, unsigned int len_)
|
||||
{
|
||||
head = array;
|
||||
len = len_;
|
||||
this->arrayZ = array;
|
||||
this->len = len_;
|
||||
}
|
||||
Supplier (hb_array_t<const Type> v)
|
||||
{
|
||||
head = v.arrayZ;
|
||||
len = v.len;
|
||||
this->arrayZ = v.arrayZ;
|
||||
this->len = v.len;
|
||||
}
|
||||
Supplier (const hb_vector_t<Type> &v)
|
||||
{
|
||||
head = (const Type *) v;
|
||||
len = v.len;
|
||||
}
|
||||
|
||||
const Type operator [] (unsigned int i) const
|
||||
{
|
||||
if (unlikely (i >= len)) return Type ();
|
||||
return head[i];
|
||||
this->arrayZ = (const Type *) v;
|
||||
this->len = v.len;
|
||||
}
|
||||
|
||||
Supplier<Type> & operator += (unsigned int count)
|
||||
{
|
||||
if (unlikely (count > len))
|
||||
count = len;
|
||||
len -= count;
|
||||
head += count;
|
||||
if (unlikely (count > this->len))
|
||||
count = this->len;
|
||||
this->len -= count;
|
||||
this->arrayZ += count;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Supplier (const Supplier<Type> &); /* Disallow copy */
|
||||
Supplier<Type>& operator= (const Supplier<Type> &); /* Disallow copy */
|
||||
|
||||
unsigned int len;
|
||||
const Type *head;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue