VecSort
Description
Sort the vector in place using a quicksort over the comparator. The comparator must return a GenericCompare integer (negative when lhs < rhs, zero when equal, positive when lhs > rhs).
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in,out | Vector handle. |
compare |
in | Comparator with GenericCompare-style return. |
Success
Returns to the caller. Elements are now in non-decreasing order according to compare. The vector length is unchanged.
Failure
Function cannot fail. A NULL comparator or invalid vector is a caller bug and aborts via LOG_FATAL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
DwarfInfo.c:623:
// Sort by low_pc to enable binary-search lookup.
if (ok && VecLen(&out->entries) > 1) {
VecSort(&out->entries, cmp_dwarf_function);
}
} else {- In
Pdb.c:659:
// Sort by RVA.
VecSort(&pending, cmp_pending);
// Re-anchor PendingPub.name_offset_in_pool to pointers into the
- In
VecInt.c:307:
// Advanced functions
case VEC_INT_SORT : {
VecSort(vec, compare_ints);
break;
}- In
Vec.Ops.c:119:
// Test VecSort function
bool test_vec_sort(void) {
WriteFmt("Testing VecSort\n");
// Create a vector of integers
- In
Vec.Ops.c:132:
// Sort the vector in ascending order
VecSort(&vec, compare_ints_asc);
// Check that the elements are sorted
- In
Vec.Ops.c:142:
// Sort the vector in descending order
VecSort(&vec, compare_ints_desc);
// Check that the elements are sorted in descending order
- In
Memory.h:114:
/// TAGS: Str, Ops, Sort
///
#define StrSort(str, compare) VecSort((str), (compare))
#ifdef __cplusplus
Last updated on