mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
10.0-base merge (roles)
This commit is contained in:
@ -126,32 +126,28 @@ public:
|
||||
return *(((Elem*)array.buffer) + idx);
|
||||
}
|
||||
|
||||
/// @returns pointer to first element; undefined behaviour if array is empty
|
||||
/// @returns pointer to first element
|
||||
Elem *front()
|
||||
{
|
||||
DBUG_ASSERT(array.elements >= 1);
|
||||
return (Elem*)array.buffer;
|
||||
}
|
||||
|
||||
/// @returns pointer to first element; undefined behaviour if array is empty
|
||||
/// @returns pointer to first element
|
||||
const Elem *front() const
|
||||
{
|
||||
DBUG_ASSERT(array.elements >= 1);
|
||||
return (const Elem*)array.buffer;
|
||||
}
|
||||
|
||||
/// @returns pointer to last element; undefined behaviour if array is empty.
|
||||
/// @returns pointer to last element
|
||||
Elem *back()
|
||||
{
|
||||
DBUG_ASSERT(array.elements >= 1);
|
||||
return ((Elem*)array.buffer) + (array.elements - 1);
|
||||
return ((Elem*)array.buffer) + array.elements - 1;
|
||||
}
|
||||
|
||||
/// @returns pointer to last element; undefined behaviour if array is empty.
|
||||
/// @returns pointer to last element
|
||||
const Elem *back() const
|
||||
{
|
||||
DBUG_ASSERT(array.elements >= 1);
|
||||
return ((const Elem*)array.buffer) + (array.elements - 1);
|
||||
return ((const Elem*)array.buffer) + array.elements - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,6 +164,11 @@ public:
|
||||
return (insert_dynamic(&array, (uchar*)&el));
|
||||
}
|
||||
|
||||
bool push(Elem &el)
|
||||
{
|
||||
return append(el);
|
||||
}
|
||||
|
||||
/// Pops the last element. Does nothing if array is empty.
|
||||
Elem& pop()
|
||||
{
|
||||
@ -228,6 +229,12 @@ public:
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SQL_ARRAY_INCLUDED */
|
||||
|
Reference in New Issue
Block a user