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