Debian Codegraph @

cextern/astrometry.net/bl-nl.h

raw
1 /*
2 # This file is part of the Astrometry.net suite.
3 # Licensed under a 3-clause BSD style license - see LICENSE
4 */
5
6 /**
7 Common header for lists of numerical types.
8
9 Expects "nl" to be #defined to the list type.
10
11 Expects "number" to be #defined to the numerical type.
12 */
13
14 #include "bl-nl.ph"
15
16 typedef bl nl;
17
18 // The "const number"s in here are mostly for pl.
19
20 Malloc nl* NLF(new)(int blocksize);
21 Pure InlineDeclare size_t NLF(size)(const nl* list);
22 void NLF(new_existing)(nl* list, int blocksize);
23 void NLF(init)(nl* list, int blocksize);
24 void NLF(reverse)(nl* list);
25 void NLF(remove_all)(nl* list);
26 void NLF(remove_all_reuse)(nl* list);
27 void NLF(free)(nl* list);
28 number* NLF(append)(nl* list, const number data);
29 void NLF(append_list)(nl* list, nl* list2);
30 void NLF(append_array)(nl* list, const number* data, size_t ndata);
31 void NLF(merge_lists)(nl* list1, nl* list2);
32 void NLF(push)(nl* list, const number data);
33 number NLF(pop)(nl* list);
34 int NLF(contains)(nl* list, const number data);
35 // Assuming the list is sorted in ascending order,
36 // does it contain the given number?
37 int NLF(sorted_contains)(nl* list, const number data);
38 // Or -1 if not found.
39 ptrdiff_t NLF(sorted_index_of)(nl* list, const number data);
40
41 #if DEFINE_SORT
42 void NLF(sort)(nl* list, int ascending);
43 #endif
44
45 Malloc number* NLF(to_array)(nl* list);
46
47 // Returns the index in the list of the given number, or -1 if it
48 // is not found.
49 ptrdiff_t NLF(index_of)(nl* list, const number data);
50 InlineDeclare number NLF(get)(nl* list, size_t n);
51 InlineDeclare number NLF(get_const)(const nl* list, size_t n);
52
53 InlineDeclare number* NLF(access)(nl* list, size_t n);
54
55 /**
56 Copy from the list, starting at index "start" for length "length",
57 into the provided array.
58 */
59 void NLF(copy)(nl* list, size_t start, size_t length, number* vdest);
60 nl* NLF(dupe)(nl* list);
61 void NLF(print)(nl* list);
62 void NLF(insert)(nl* list, size_t indx, const number data);
63 size_t NLF(insert_ascending)(nl* list, const number n);
64 size_t NLF(insert_descending)(nl* list, const number n);
65 // Returns the index at which the element was added, or -1 if it's a duplicate.
66 ptrdiff_t NLF(insert_unique_ascending)(nl* list, const number p);
67 void NLF(set)(nl* list, size_t ind, const number value);
68 void NLF(remove)(nl* list, size_t ind);
69 void NLF(remove_index_range)(nl* list, size_t start, size_t length);
70 // See also sorted_index_of, which should be faster.
71 // Or -1 if not found
72 ptrdiff_t NLF(find_index_ascending)(nl* list, const number value);
73
74 nl* NLF(merge_ascending)(nl* list1, nl* list2);
75
76 // returns the index of the removed value, or -1 if it didn't
77 // exist in the list.
78 ptrdiff_t NLF(remove_value)(nl* list, const number value);
79
80 int NLF(check_consistency)(nl* list);
81 int NLF(check_sorted_ascending)(nl* list, int isunique);
82 int NLF(check_sorted_descending)(nl* list, int isunique);
83
84