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