]>
Commit | Line | Data |
---|---|---|
4983ca93 | 1 | /** @file\r |
125c2cf4 | 2 | Library used for sorting and comparison routines.\r |
4983ca93 | 3 | \r |
ae591c14 | 4 | Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. <BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
4983ca93 | 6 | \r |
7 | **/\r | |
a405b86d | 8 | #ifndef __SORT_LIB_H__\r |
4983ca93 | 9 | #define __SORT_LIB_H__\r |
10 | \r | |
11 | /**\r | |
a405b86d | 12 | Prototype for comparison function for any two element types.\r |
4983ca93 | 13 | \r |
a405b86d | 14 | @param[in] Buffer1 The pointer to first buffer.\r |
15 | @param[in] Buffer2 The pointer to second buffer.\r | |
4983ca93 | 16 | \r |
a31bd33c | 17 | @retval 0 Buffer1 equal to Buffer2.\r |
a405b86d | 18 | @return <0 Buffer1 is less than Buffer2.\r |
19 | @return >0 Buffer1 is greater than Buffer2.\r | |
4983ca93 | 20 | **/\r |
21 | typedef\r | |
22 | INTN\r | |
23 | (EFIAPI *SORT_COMPARE)(\r | |
b3011f40 | 24 | IN CONST VOID *Buffer1,\r |
25 | IN CONST VOID *Buffer2\r | |
4983ca93 | 26 | );\r |
27 | \r | |
28 | /**\r | |
29 | Function to perform a Quick Sort on a buffer of comparable elements.\r | |
30 | \r | |
31 | Each element must be equally sized.\r | |
32 | \r | |
a31bd33c | 33 | If BufferToSort is NULL, then ASSERT.\r |
34 | If CompareFunction is NULL, then ASSERT.\r | |
4983ca93 | 35 | \r |
a405b86d | 36 | If Count is < 2 , then perform no action.\r |
37 | If Size is < 1 , then perform no action.\r | |
4983ca93 | 38 | \r |
4ff7e37b ED |
39 | @param[in, out] BufferToSort On call, a Buffer of (possibly sorted) elements;\r |
40 | on return, a buffer of sorted elements.\r | |
41 | @param[in] Count The number of elements in the buffer to sort.\r | |
42 | @param[in] ElementSize The size of an element in bytes.\r | |
43 | @param[in] CompareFunction The function to call to perform the comparison\r | |
44 | of any two elements.\r | |
4983ca93 | 45 | **/\r |
46 | VOID\r | |
47 | EFIAPI\r | |
48 | PerformQuickSort (\r | |
b3011f40 | 49 | IN OUT VOID *BufferToSort,\r |
50 | IN CONST UINTN Count,\r | |
51 | IN CONST UINTN ElementSize,\r | |
52 | IN SORT_COMPARE CompareFunction\r | |
4983ca93 | 53 | );\r |
54 | \r | |
125c2cf4 | 55 | \r |
56 | /**\r | |
57 | Function to compare 2 device paths for use as CompareFunction.\r | |
58 | \r | |
a405b86d | 59 | @param[in] Buffer1 The pointer to Device Path to compare.\r |
60 | @param[in] Buffer2 The pointer to second DevicePath to compare.\r | |
125c2cf4 | 61 | \r |
11d2decf | 62 | @retval 0 Buffer1 equal to Buffer2.\r |
63 | @return < 0 Buffer1 is less than Buffer2.\r | |
1e6e84c7 | 64 | @return > 0 Buffer1 is greater than Buffer2.\r |
125c2cf4 | 65 | **/\r |
66 | INTN\r | |
11d2decf | 67 | EFIAPI\r |
125c2cf4 | 68 | DevicePathCompare (\r |
b3011f40 | 69 | IN CONST VOID *Buffer1,\r |
70 | IN CONST VOID *Buffer2\r | |
125c2cf4 | 71 | );\r |
11d2decf | 72 | \r |
73 | /**\r | |
74 | Function to compare 2 strings without regard to case of the characters.\r | |
75 | \r | |
a405b86d | 76 | @param[in] Buffer1 The pointer to String to compare (CHAR16**).\r |
77 | @param[in] Buffer2 The pointer to second String to compare (CHAR16**).\r | |
11d2decf | 78 | \r |
79 | @retval 0 Buffer1 equal to Buffer2.\r | |
80 | @return < 0 Buffer1 is less than Buffer2.\r | |
1e6e84c7 | 81 | @return > 0 Buffer1 is greater than Buffer2.\r |
11d2decf | 82 | **/\r |
83 | INTN\r | |
84 | EFIAPI\r | |
85 | StringNoCaseCompare (\r | |
b3011f40 | 86 | IN CONST VOID *Buffer1,\r |
87 | IN CONST VOID *Buffer2\r | |
11d2decf | 88 | );\r |
89 | \r | |
a405b86d | 90 | /**\r |
91 | Function to compare 2 strings.\r | |
92 | \r | |
93 | @param[in] Buffer1 The pointer to String to compare (CHAR16**).\r | |
94 | @param[in] Buffer2 The pointer to second String to compare (CHAR16**).\r | |
95 | \r | |
96 | @retval 0 Buffer1 equal to Buffer2.\r | |
97 | @return < 0 Buffer1 is less than Buffer2.\r | |
98 | @return > 0 Buffer1 is greater than Buffer2.\r | |
99 | **/\r | |
100 | INTN\r | |
101 | EFIAPI\r | |
102 | StringCompare (\r | |
103 | IN CONST VOID *Buffer1,\r | |
104 | IN CONST VOID *Buffer2\r | |
105 | );\r | |
106 | \r | |
4983ca93 | 107 | #endif //__SORT_LIB_H__\r |