]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Include/Library/SortLib.h
updating headers from code review.
[mirror_edk2.git] / ShellPkg / Include / Library / SortLib.h
1 /** @file
2 Library used for sorting and comparison routines.
3
4 Copyright (c) 2009, Intel Corporation
5 All rights reserved. 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 VOID *Buffer1,
32 IN 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 DevicePathCompare (
75 IN VOID *Buffer1,
76 IN VOID *Buffer2
77 );
78 #endif //__SORT_LIB_H__