]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Include/Library/SortLib.h
bf3755866c533af7efe5ed6e49364bb3e6ad3687
[mirror_edk2.git] / ShellPkg / Include / Library / SortLib.h
1 /** @file
2 Library used for sorting and comparison routines.
3
4 Copyright (c) 2009-2010, Intel Corporation.All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #if !defined(__SORT_LIB_H__)
16 #define __SORT_LIB_H__
17
18 /**
19 Prototype for comparison function for any 2 element types.
20
21 @param[in] Buffer1 Pointer to first buffer.
22 @param[in] Buffer2 Pointer to second buffer.
23
24 @retval 0 Buffer1 equal to Buffer2.
25 @return < 0 Buffer1 is less than Buffer2.
26 @return > 0 Buffer1 is greater than Buffer2.
27 **/
28 typedef
29 INTN
30 (EFIAPI *SORT_COMPARE)(
31 IN CONST VOID *Buffer1,
32 IN CONST VOID *Buffer2
33 );
34
35 /**
36 Function to perform a Quick Sort on a buffer of comparable elements.
37
38 Each element must be equally sized.
39
40 If BufferToSort is NULL, then ASSERT.
41 If CompareFunction is NULL, then ASSERT.
42
43 If Count is < 2 then perform no action.
44 If Size is < 1 then perform no action.
45
46 @param[in,out] BufferToSort On call a Buffer of (possibly sorted) elements
47 on return a buffer of sorted elements.
48 @param[in] Count The number of elements in the buffer to sort
49 @param[in] ElementSize Size of an element in bytes.
50 @param[in] CompareFunction The function to call to perform the comparison
51 of any 2 elements.
52 **/
53 VOID
54 EFIAPI
55 PerformQuickSort (
56 IN OUT VOID *BufferToSort,
57 IN CONST UINTN Count,
58 IN CONST UINTN ElementSize,
59 IN SORT_COMPARE CompareFunction
60 );
61
62
63 /**
64 Function to compare 2 device paths for use as CompareFunction.
65
66 @param[in] Buffer1 Pointer to Device Path to compare.
67 @param[in] Buffer2 Pointer to second DevicePath to compare.
68
69 @retval 0 Buffer1 equal to Buffer2.
70 @return < 0 Buffer1 is less than Buffer2.
71 @return > 0 Buffer1 is greater than Buffer2.
72 **/
73 INTN
74 EFIAPI
75 DevicePathCompare (
76 IN CONST VOID *Buffer1,
77 IN CONST VOID *Buffer2
78 );
79
80 /**
81 Function to compare 2 strings without regard to case of the characters.
82
83 @param[in] Buffer1 Pointer to String to compare (CHAR16**).
84 @param[in] Buffer2 Pointer to second String to compare (CHAR16**).
85
86 @retval 0 Buffer1 equal to Buffer2.
87 @return < 0 Buffer1 is less than Buffer2.
88 @return > 0 Buffer1 is greater than Buffer2.
89 **/
90 INTN
91 EFIAPI
92 StringNoCaseCompare (
93 IN CONST VOID *Buffer1,
94 IN CONST VOID *Buffer2
95 );
96
97 #endif //__SORT_LIB_H__