1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 // Generic unstable sorting routines.
12 
13 #ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_
14 #define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_
15 
16 #include "typedefs.h"
17 #include "common_types.h"
18 
19 namespace webrtc
20 {
21     enum Type
22     {
23         TYPE_Word8,
24         TYPE_UWord8,
25         TYPE_Word16,
26         TYPE_UWord16,
27         TYPE_Word32,
28         TYPE_UWord32,
29         TYPE_Word64,
30         TYPE_UWord64,
31         TYPE_Float32,
32         TYPE_Float64
33     };
34     // Sorts intrinsic data types.
35     //
36     // data          [in/out] A pointer to an array of intrinsic type.
37     //               Upon return it will be sorted in ascending order.
38     // numOfElements The number of elements in the array.
39     // dataType      Enum corresponding to the type of the array.
40     //
41     // returns 0 on success, -1 on failure.
42     WebRtc_Word32 Sort(void* data, WebRtc_UWord32 numOfElements, Type dataType);
43 
44     // Sorts arbitrary data types. This requires an array of intrinsically typed
45     // key values which will be used to sort the data array. There must be a
46     // one-to-one correspondence between data elements and key elements, with
47     // corresponding elements sharing the same position in their respective
48     // arrays.
49     //
50     // data          [in/out] A pointer to an array of arbitrary type.
51     //               Upon return it will be sorted in ascending order.
52     // key           [in] A pointer to an array of keys used to sort the
53     //               data array.
54     // numOfElements The number of elements in the arrays.
55     // sizeOfElement The size, in bytes, of the data array.
56     // keyType       Enum corresponding to the type of the key array.
57     //
58     // returns 0 on success, -1 on failure.
59     //
60     WebRtc_Word32 KeySort(void* data, void* key, WebRtc_UWord32 numOfElements,
61                           WebRtc_UWord32 sizeOfElement, Type keyType);
62 }
63 
64 #endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_SORT_H_
65