OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 #ifndef VBOOT_REFERENCE_QSORT_H_ | 5 #ifndef VBOOT_REFERENCE_QSORT_H_ |
6 #define VBOOT_REFERENCE_QSORT_H_ | 6 #define VBOOT_REFERENCE_QSORT_H_ |
7 | 7 |
8 #define MAX_QUICK_SORT_ELEMENT_SIZE 512 | 8 #define MAX_QUICK_SORT_ELEMENT_SIZE 512 |
9 | 9 |
10 /* QuickSort() is an in-place, and unstable quick sort implementation. | 10 /* QuickSort() is an in-place, and unstable quick sort implementation. |
11 * Given a compare function, this function sorts elements for you. | 11 * Given a compare function, this function sorts elements for you. |
12 * 'elements' points to the base of un-sorted array. | 12 * 'elements' points to the base of un-sorted array. |
13 * 'number_of_elements' indicates the number of elements in array. | 13 * 'number_of_elements' indicates the number of elements in array. |
14 * 'size' indicates the size (in bytes) of an element unit. | 14 * 'size' indicates the size (in bytes) of an element unit. |
15 * The 'compare_function' should return true if 'a' precedes 'b'. | 15 * The 'compare_function' should return true if 'a' precedes 'b'. |
16 * | 16 * |
17 * NOTE: For performance issue, we reserve a static buffer for swap. | 17 * NOTE: For performance issue, we reserve a static buffer for swap. |
18 * So that the 'size' cannot exceed the buffer size | 18 * So that the 'size' cannot exceed the buffer size |
19 * (MAX_QUICK_SORT_ELEMENT_SIZE). */ | 19 * (MAX_QUICK_SORT_ELEMENT_SIZE). */ |
20 void QuickSort(void *elements, int number_of_elements, int size, | 20 void QuickSort(void *elements, int number_of_elements, int size, |
21 int (*compare_function)(const void *a, const void *b)); | 21 int (*compare_function)(const void *a, const void *b)); |
22 | 22 |
23 #endif /* VBOOT_REFERENCE_QSORT_H_ */ | 23 #endif /* VBOOT_REFERENCE_QSORT_H_ */ |
OLD | NEW |