]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/SortLib.h
Add check before use to make code run more safer.
[mirror_edk2.git] / ShellPkg / Include / Library / SortLib.h
CommitLineData
4983ca93 1/** @file\r
125c2cf4 2 Library used for sorting and comparison routines.\r
4983ca93 3\r
fbec9c0f 4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
1e6e84c7 5 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
4983ca93 9\r
1e6e84c7 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
4983ca93 12\r
13**/\r
14\r
a405b86d 15#ifndef __SORT_LIB_H__\r
4983ca93 16#define __SORT_LIB_H__\r
17\r
18/**\r
a405b86d 19 Prototype for comparison function for any two element types.\r
4983ca93 20\r
a405b86d 21 @param[in] Buffer1 The pointer to first buffer.\r
22 @param[in] Buffer2 The pointer to second buffer.\r
4983ca93 23\r
a31bd33c 24 @retval 0 Buffer1 equal to Buffer2.\r
a405b86d 25 @return <0 Buffer1 is less than Buffer2.\r
26 @return >0 Buffer1 is greater than Buffer2.\r
4983ca93 27**/\r
28typedef\r
29INTN\r
30(EFIAPI *SORT_COMPARE)(\r
b3011f40 31 IN CONST VOID *Buffer1,\r
32 IN CONST VOID *Buffer2\r
4983ca93 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
a31bd33c 40 If BufferToSort is NULL, then ASSERT.\r
41 If CompareFunction is NULL, then ASSERT.\r
4983ca93 42\r
a405b86d 43 If Count is < 2 , then perform no action.\r
44 If Size is < 1 , then perform no action.\r
4983ca93 45\r
a405b86d 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 The size of an element in bytes.\r
1e6e84c7 50 @param[in] CompareFunction The function to call to perform the comparison\r
a405b86d 51 of any two elements.\r
4983ca93 52**/\r
53VOID\r
54EFIAPI\r
55PerformQuickSort (\r
b3011f40 56 IN OUT VOID *BufferToSort,\r
57 IN CONST UINTN Count,\r
58 IN CONST UINTN ElementSize,\r
59 IN SORT_COMPARE CompareFunction\r
4983ca93 60 );\r
61\r
125c2cf4 62\r
63/**\r
64 Function to compare 2 device paths for use as CompareFunction.\r
65\r
a405b86d 66 @param[in] Buffer1 The pointer to Device Path to compare.\r
67 @param[in] Buffer2 The pointer to second DevicePath to compare.\r
125c2cf4 68\r
11d2decf 69 @retval 0 Buffer1 equal to Buffer2.\r
70 @return < 0 Buffer1 is less than Buffer2.\r
1e6e84c7 71 @return > 0 Buffer1 is greater than Buffer2.\r
125c2cf4 72**/\r
73INTN\r
11d2decf 74EFIAPI\r
125c2cf4 75DevicePathCompare (\r
b3011f40 76 IN CONST VOID *Buffer1,\r
77 IN CONST VOID *Buffer2\r
125c2cf4 78 );\r
11d2decf 79\r
80/**\r
81 Function to compare 2 strings without regard to case of the characters.\r
82\r
a405b86d 83 @param[in] Buffer1 The pointer to String to compare (CHAR16**).\r
84 @param[in] Buffer2 The pointer to second String to compare (CHAR16**).\r
11d2decf 85\r
86 @retval 0 Buffer1 equal to Buffer2.\r
87 @return < 0 Buffer1 is less than Buffer2.\r
1e6e84c7 88 @return > 0 Buffer1 is greater than Buffer2.\r
11d2decf 89**/\r
90INTN\r
91EFIAPI\r
92StringNoCaseCompare (\r
b3011f40 93 IN CONST VOID *Buffer1,\r
94 IN CONST VOID *Buffer2\r
11d2decf 95 );\r
96\r
a405b86d 97/**\r
98 Function to compare 2 strings.\r
99\r
100 @param[in] Buffer1 The pointer to String to compare (CHAR16**).\r
101 @param[in] Buffer2 The pointer to second String to compare (CHAR16**).\r
102\r
103 @retval 0 Buffer1 equal to Buffer2.\r
104 @return < 0 Buffer1 is less than Buffer2.\r
105 @return > 0 Buffer1 is greater than Buffer2.\r
106**/\r
107INTN\r
108EFIAPI\r
109StringCompare (\r
110 IN CONST VOID *Buffer1,\r
111 IN CONST VOID *Buffer2\r
112 );\r
113\r
4983ca93 114#endif //__SORT_LIB_H__\r