Commit 3098b6cf authored by Sergei Golubchik's avatar Sergei Golubchik

qsort2, pop, push methods for Dynamic_array<>

parent b221ec65
...@@ -130,6 +130,16 @@ template <class Elem> class Dynamic_array ...@@ -130,6 +130,16 @@ template <class Elem> class Dynamic_array
return (insert_dynamic(&array, (uchar*)&el)); return (insert_dynamic(&array, (uchar*)&el));
} }
bool push(Elem &el)
{
return append(el);
}
Elem *pop()
{
return (Elem*)pop_dynamic(&array);
}
size_t elements() size_t elements()
{ {
return array.elements; return array.elements;
...@@ -168,6 +178,12 @@ template <class Elem> class Dynamic_array ...@@ -168,6 +178,12 @@ template <class Elem> class Dynamic_array
{ {
my_qsort(array.buffer, array.elements, sizeof(Elem), (qsort_cmp)cmp_func); my_qsort(array.buffer, array.elements, sizeof(Elem), (qsort_cmp)cmp_func);
} }
typedef int (*CMP_FUNC2)(const Elem *el1, const Elem *el2, void *);
void sort(CMP_FUNC2 cmp_func, void *data)
{
my_qsort2(array.buffer, array.elements, sizeof(Elem), (qsort2_cmp)cmp_func, data);
}
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment