summaryrefslogtreecommitdiff
path: root/sql/sql_array.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-10-29 15:08:44 +0100
committerSergei Golubchik <sergii@pisem.net>2013-10-29 15:08:44 +0100
commit0fdb3bcfdbfa5d7cad28adc1c0f7c0958cdab2e0 (patch)
tree7d6a1d36b975e2b1bb8d9ffd3b7511ec0694349e /sql/sql_array.h
parent7dc48ae327ad27205dffe0cec16b445d01529f84 (diff)
parentfef416699009b78366d9eec937c01822b531f518 (diff)
downloadmariadb-git-0fdb3bcfdbfa5d7cad28adc1c0f7c0958cdab2e0.tar.gz
10.0-base merge (roles)
Diffstat (limited to 'sql/sql_array.h')
-rw-r--r--sql/sql_array.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/sql/sql_array.h b/sql/sql_array.h
index b527f26b186..8202e94ce41 100644
--- a/sql/sql_array.h
+++ b/sql/sql_array.h
@@ -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 */