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