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_INCLUDE_SORT_H_
14#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SORT_H_
15
16#include "webrtc/common_types.h"
17#include "webrtc/typedefs.h"
18
19namespace webrtc {
20
21enum Type {
22  TYPE_Word8,
23  TYPE_UWord8,
24  TYPE_Word16,
25  TYPE_UWord16,
26  TYPE_Word32,
27  TYPE_UWord32,
28  TYPE_Word64,
29  TYPE_UWord64,
30  TYPE_Float32,
31  TYPE_Float64
32};
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// num_of_elements The number of elements in the array.
39// data_type       Enum corresponding to the type of the array.
40//
41// returns 0 on success, -1 on failure.
42int32_t Sort(void* data, uint32_t num_of_elements, Type data_type);
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// num_of_elements The number of elements in the arrays.
55// size_of_element The size, in bytes, of the data array.
56// key_type        Enum corresponding to the type of the key array.
57//
58// returns 0 on success, -1 on failure.
59//
60int32_t KeySort(void* data, void* key, uint32_t num_of_elements,
61                uint32_t size_of_element, Type key_type);
62
63}  // namespace webrtc
64
65#endif  // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_SORT_H_
66