/* Type behaving similar to vectorized vars defined using __attribute__((vector_size(...))), * basically a fixed-size bitset. We can't use the compiler type because hb_vector_t cannot
* guarantee alignment requirements. */ template <typename elt_t, unsignedint byte_size> struct hb_vector_size_t
{
elt_t& operator [] (unsignedint i) { return v[i]; } const elt_t& operator [] (unsignedint i) const { return v[i]; }
void init0 ()
{ for (unsignedint i = 0; i < ARRAY_LENGTH (v); i++)
v[i] = 0;
} void init1 ()
{ for (unsignedint i = 0; i < ARRAY_LENGTH (v); i++)
v[i] = (elt_t) -1;
}
template <typename Op>
hb_vector_size_t process (const Op& op) const
{
hb_vector_size_t r; for (unsignedint i = 0; i < ARRAY_LENGTH (v); i++)
r.v[i] = op (v[i]); return r;
} template <typename Op>
hb_vector_size_t process (const Op& op, const hb_vector_size_t &o) const
{
hb_vector_size_t r; for (unsignedint i = 0; i < ARRAY_LENGTH (v); i++)
r.v[i] = op (v[i], o.v[i]); return r;
}
hb_vector_size_t operator | (const hb_vector_size_t &o) const
{ return process (hb_bitwise_or, o); }
hb_vector_size_t operator & (const hb_vector_size_t &o) const
{ return process (hb_bitwise_and, o); }
hb_vector_size_t operator ^ (const hb_vector_size_t &o) const
{ return process (hb_bitwise_xor, o); }
hb_vector_size_t operator ~ () const
{ return process (hb_bitwise_neg); }
hb_array_t<const elt_t> iter () const
{ return hb_array (v); }
// Writes out page values to the array p. Returns the number of values // written. At most size codepoints will be written. unsignedint write (uint32_t base, unsignedint start_value,
hb_codepoint_t *p, unsignedint size) const
{ unsignedint start_v = start_value / ELT_BITS; unsignedint start_bit = start_value & ELT_MASK; unsignedint count = 0; for (unsigned i = start_v; i < len () && count < size; i++)
{
elt_t bits = v[i];
uint32_t v_base = base | (i * ELT_BITS); for (unsignedint j = start_bit; j < ELT_BITS && count < size; j++)
{ if ((elt_t(1) << j) & bits) {
*p++ = v_base | j;
count++;
}
}
start_bit = 0;
} return count;
}
// Writes out the values NOT in this page to the array p. Returns the // number of values written. At most size codepoints will be written. // Returns the number of codepoints written. next_value holds the next value // that should be written (if not present in this page). This is used to fill // any missing value gaps between this page and the previous page, if any. // next_value is updated to one more than the last value present in this page. unsignedint write_inverted (uint32_t base, unsignedint start_value,
hb_codepoint_t *p, unsignedint size,
hb_codepoint_t *next_value) const
{ unsignedint start_v = start_value / ELT_BITS; unsignedint start_bit = start_value & ELT_MASK; unsignedint count = 0; for (unsigned i = start_v; i < len () && count < size; i++)
{
elt_t bits = v[i];
uint32_t v_offset = i * ELT_BITS; for (unsignedint j = start_bit; j < ELT_BITS && count < size; j++)
{ if ((elt_t(1) << j) & bits)
{
hb_codepoint_t value = base | v_offset | j; // Emit all the missing values from next_value up to value - 1. for (hb_codepoint_t k = *next_value; k < value && count < size; k++)
{
*p++ = k;
count++;
} // Skip over this value;
*next_value = value + 1;
}
}
start_bit = 0;
} return count;
}
booloperator == (const hb_bit_page_t &other) const { return is_equal (other); } bool is_equal (const hb_bit_page_t &other) const
{ for (unsigned i = 0; i < len (); i++) if (v[i] != other.v[i]) returnfalse; returntrue;
} booloperator <= (const hb_bit_page_t &larger_page) const { return is_subset (larger_page); } bool is_subset (const hb_bit_page_t &larger_page) const
{ if (has_population () && larger_page.has_population () &&
population > larger_page.population) returnfalse;
for (unsigned i = 0; i < len (); i++) if (~larger_page.v[i] & v[i]) returnfalse; returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.