-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist_sort.h
More file actions
36 lines (29 loc) · 1.09 KB
/
list_sort.h
File metadata and controls
36 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Type declarations associated with sorting linked lists, and a registry of
// known sorting functions.
//
// Author: Joe Zbiciak <joe.zbiciak@leftturnonly.info>
// SPDX-License-Identifier: CC-BY-SA-4.0
#ifndef LIST_SORT_H_
#define LIST_SORT_H_
#include <stdbool.h>
#include <stddef.h>
#include "list_node.h"
// Function type for node comparison functions. Returns true if the first
// argument is less than the second argument.
typedef bool ListNodeCompareFxn(const ListNode*, const ListNode*);
// Function type for list sort functions. Returns the new head of a list.
typedef ListNode *ListSortFxn(ListNode*, ListNodeCompareFxn*);
// Defines a registry entry for the sorting algorithm registry.
typedef struct {
const char *name;
ListSortFxn *fxn;
} SortRegistryEntry;
// Defines a registry of sorting algorithms for the benchmarks to refer to, so
// that we don't have to edit the benchmark drivers every time we add an
// algorithm.
typedef struct sort_registry {
size_t length;
const SortRegistryEntry *entry;
} SortRegistry;
extern const SortRegistry sort_registry;
#endif // LIST_SORT_H_