[arrays] Port hb_vector_t.qsort() to hb_array_t's
This commit is contained in:
parent
e3face8e79
commit
61de55bf49
|
@ -572,6 +572,10 @@ struct hb_array_t
|
||||||
return arrayZ[i];
|
return arrayZ[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> inline operator T * (void) const { return arrayZ; }
|
||||||
|
|
||||||
|
inline Type * operator & (void) const { return arrayZ; }
|
||||||
|
|
||||||
inline unsigned int get_size (void) const { return len * sizeof (Type); }
|
inline unsigned int get_size (void) const { return len * sizeof (Type); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -595,9 +599,15 @@ struct hb_array_t
|
||||||
return not_found;
|
return not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> inline operator T * (void) const { return arrayZ; }
|
inline void qsort (int (*cmp)(const void*, const void*))
|
||||||
|
{
|
||||||
inline Type * operator & (void) const { return arrayZ; }
|
::qsort (arrayZ, len, sizeof (Type), cmp);
|
||||||
|
}
|
||||||
|
inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
|
||||||
|
{
|
||||||
|
end = MIN (end, len);
|
||||||
|
::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp);
|
||||||
|
}
|
||||||
|
|
||||||
inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
|
inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -221,15 +221,9 @@ struct hb_vector_t
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void qsort (int (*cmp)(const void*, const void*))
|
inline void qsort (int (*cmp)(const void*, const void*))
|
||||||
{
|
{ as_array ().qsort (cmp); }
|
||||||
::qsort (arrayZ(), len, sizeof (Type), cmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
|
inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1)
|
||||||
{
|
{ as_array ().qsort (start, end); }
|
||||||
end = MIN (end, len);
|
|
||||||
::qsort (arrayZ() + start, end - start, sizeof (Type), Type::cmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline Type *lsearch (const T &x, Type *not_found = nullptr)
|
inline Type *lsearch (const T &x, Type *not_found = nullptr)
|
||||||
|
|
Loading…
Reference in New Issue