mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
vector.h: Add AST_VECTOR_SORT()
Allows a vector to be sorted in-place, rather than only during insertion. Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780
This commit is contained in:
committed by
George Joseph
parent
f6afac1b37
commit
4fec6da25b
@@ -357,6 +357,16 @@ AST_VECTOR(ast_vector_string, char *);
|
|||||||
res; \
|
res; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sort a vector in-place
|
||||||
|
*
|
||||||
|
* \param vec Vector to sort
|
||||||
|
* \param cmp A memcmp compatible compare function
|
||||||
|
*/
|
||||||
|
#define AST_VECTOR_SORT(vec, cmp) ({ \
|
||||||
|
qsort((vec)->elems, (vec)->current, sizeof(typeof((vec)->elems[0])), cmp); \
|
||||||
|
})
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Remove an element from a vector by index.
|
* \brief Remove an element from a vector by index.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user