[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>
|
template <typename Type>
|
||||||
struct Supplier
|
struct Supplier : hb_array_t<const Type>
|
||||||
{
|
{
|
||||||
Supplier (const Type *array, unsigned int len_)
|
Supplier (const Type *array, unsigned int len_)
|
||||||
{
|
{
|
||||||
head = array;
|
this->arrayZ = array;
|
||||||
len = len_;
|
this->len = len_;
|
||||||
}
|
}
|
||||||
Supplier (hb_array_t<const Type> v)
|
Supplier (hb_array_t<const Type> v)
|
||||||
{
|
{
|
||||||
head = v.arrayZ;
|
this->arrayZ = v.arrayZ;
|
||||||
len = v.len;
|
this->len = v.len;
|
||||||
}
|
}
|
||||||
Supplier (const hb_vector_t<Type> &v)
|
Supplier (const hb_vector_t<Type> &v)
|
||||||
{
|
{
|
||||||
head = (const Type *) v;
|
this->arrayZ = (const Type *) v;
|
||||||
len = v.len;
|
this->len = v.len;
|
||||||
}
|
|
||||||
|
|
||||||
const Type operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
if (unlikely (i >= len)) return Type ();
|
|
||||||
return head[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Supplier<Type> & operator += (unsigned int count)
|
Supplier<Type> & operator += (unsigned int count)
|
||||||
{
|
{
|
||||||
if (unlikely (count > len))
|
if (unlikely (count > this->len))
|
||||||
count = len;
|
count = this->len;
|
||||||
len -= count;
|
this->len -= count;
|
||||||
head += count;
|
this->arrayZ += count;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Supplier (const Supplier<Type> &); /* Disallow copy */
|
Supplier (const Supplier<Type> &); /* Disallow copy */
|
||||||
Supplier<Type>& operator= (const Supplier<Type> &); /* Disallow copy */
|
Supplier<Type>& operator= (const Supplier<Type> &); /* Disallow copy */
|
||||||
|
|
||||||
unsigned int len;
|
|
||||||
const Type *head;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue