]>
Commit | Line | Data |
---|---|---|
4983ca93 | 1 | /** @file\r |
2 | Library used for sorting routines.\r | |
3 | \r | |
4 | Copyright (c) 2009, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #if !defined(__SORT_LIB_H__)\r | |
16 | #define __SORT_LIB_H__\r | |
17 | \r | |
18 | /**\r | |
19 | Prototype for comparison function for any 2 element types.\r | |
20 | \r | |
21 | @param[in] Buffer1 pointer to first buffer\r | |
22 | @param[in] Buffer2 pointer to second buffer \r | |
23 | \r | |
24 | @retval 0 Buffer1 equal to Buffer2\r | |
25 | @return < 0 Buffer1 is less than Buffer2\r | |
26 | @return > 0 Buffer1 is greater than Buffer2\r | |
27 | **/\r | |
28 | typedef\r | |
29 | INTN\r | |
30 | (EFIAPI *SORT_COMPARE)(\r | |
31 | IN VOID *Buffer1,\r | |
32 | IN VOID *Buffer2\r | |
33 | );\r | |
34 | \r | |
35 | /**\r | |
36 | Function to perform a Quick Sort on a buffer of comparable elements.\r | |
37 | \r | |
38 | Each element must be equally sized.\r | |
39 | \r | |
40 | if BufferToSort is NULL, then ASSERT.\r | |
41 | if CompareFunction is NULL, then ASSERT.\r | |
42 | \r | |
43 | if Count is < 2 then perform no action.\r | |
44 | if Size is < 1 then perform no action.\r | |
45 | \r | |
46 | @param[in,out] BufferToSort on call a Buffer of (possibly sorted) elements\r | |
47 | on return a buffer of sorted elements\r | |
48 | @param[in] Count the number of elements in the buffer to sort\r | |
49 | @param[in] ElementSize Size of an element in bytes\r | |
50 | @param[in] CompareFunction The function to call to perform the comparison \r | |
51 | of any 2 elements\r | |
52 | **/\r | |
53 | VOID\r | |
54 | EFIAPI\r | |
55 | PerformQuickSort (\r | |
56 | IN OUT VOID *BufferToSort,\r | |
57 | IN CONST UINTN Count,\r | |
58 | IN CONST UINTN ElementSize,\r | |
59 | IN SORT_COMPARE CompareFunction\r | |
60 | );\r | |
61 | \r | |
62 | #endif //__SORT_LIB_H__\r |