nemea-common
1.6.3
include
counting_sort.h
Go to the documentation of this file.
1
8
/*
9
* Copyright (C) 2018 CESNET
10
*
11
* LICENSE TERMS
12
*
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following conditions
15
* are met:
16
* 1. Redistributions of source code must retain the above copyright
17
* notice, this list of conditions and the following disclaimer.
18
* 2. Redistributions in binary form must reproduce the above copyright
19
* notice, this list of conditions and the following disclaimer in
20
* the documentation and/or other materials provided with the
21
* distribution.
22
* 3. Neither the name of the Company nor the names of its contributors
23
* may be used to endorse or promote products derived from this
24
* software without specific prior written permission.
25
*
26
* ALTERNATIVELY, provided that this notice is retained in full, this
27
* product may be distributed under the terms of the GNU General Public
28
* License (GPL) version 2 or later, in which case the provisions
29
* of the GPL apply INSTEAD OF those given above.
30
*
31
* This software is provided ``as is'', and any express or implied
32
* warranties, including, but not limited to, the implied warranties of
33
* merchantability and fitness for a particular purpose are disclaimed.
34
* In no event shall the company or contributors be liable for any
35
* direct, indirect, incidental, special, exemplary, or consequential
36
* damages (including, but not limited to, procurement of substitute
37
* goods or services; loss of use, data, or profits; or business
38
* interruption) however caused and on any theory of liability, whether
39
* in contract, strict liability, or tort (including negligence or
40
* otherwise) arising in any way out of the use of this software, even
41
* if advised of the possibility of such damage.
42
*
43
*/
44
45
#ifndef _NEMEA_COMMON_COUNTING_SORT_
46
#define _NEMEA_COMMON_COUNTING_SORT_
47
48
#include <stdint.h>
49
53
typedef
enum
{
54
CS_ORDER_ASC
= 0,
55
CS_ORDER_DSC
56
}
cs_order
;
57
61
typedef
enum
{
62
CS_SUCCESS
= 0,
63
CS_BAD_PARAM
,
64
CS_MEMORY
,
65
CS_BAD_INDEX
66
}
cs_ret_code
;
67
87
cs_ret_code
counting_sort
(
const
void
*input,
void
*output, uint32_t count, uint32_t size, uint32_t key_min,
88
uint32_t key_max,
cs_order
order, uint32_t (*get_key) (
const
void
*));
89
90
#endif
/* _NEMEA_COMMON_COUNTING_SORT_ */
counting_sort
cs_ret_code counting_sort(const void *input, void *output, uint32_t count, uint32_t size, uint32_t key_min, uint32_t key_max, cs_order order, uint32_t(*get_key)(const void *))
cs_ret_code
cs_ret_code
Possible return codes of counting sort function.
Definition:
counting_sort.h:61
CS_BAD_INDEX
@ CS_BAD_INDEX
Definition:
counting_sort.h:65
CS_BAD_PARAM
@ CS_BAD_PARAM
Definition:
counting_sort.h:63
CS_SUCCESS
@ CS_SUCCESS
Definition:
counting_sort.h:62
CS_MEMORY
@ CS_MEMORY
Definition:
counting_sort.h:64
cs_order
cs_order
Possible orders - ascending and descending.
Definition:
counting_sort.h:53
CS_ORDER_DSC
@ CS_ORDER_DSC
Definition:
counting_sort.h:55
CS_ORDER_ASC
@ CS_ORDER_ASC
Definition:
counting_sort.h:54
Generated by
1.9.6