@@ -15,13 +15,12 @@ Python recipe (https://rhettinger.wordpress.com/2010/02/06/lost-knowledge/)
15
15
16
16
#pragma once
17
17
18
- #include "pandas/inline_helper.h"
19
18
#include <math.h>
20
19
#include <stdio.h>
21
20
#include <stdlib.h>
22
21
#include <string.h>
23
22
24
- PANDAS_INLINE float __skiplist_nanf (void ) {
23
+ static inline float __skiplist_nanf (void ) {
25
24
const union {
26
25
int __i ;
27
26
float __f ;
@@ -30,7 +29,7 @@ PANDAS_INLINE float __skiplist_nanf(void) {
30
29
}
31
30
#define PANDAS_NAN ((double)__skiplist_nanf())
32
31
33
- PANDAS_INLINE double Log2 (double val ) { return log (val ) / log (2. ); }
32
+ static inline double Log2 (double val ) { return log (val ) / log (2. ); }
34
33
35
34
typedef struct node_t node_t ;
36
35
@@ -51,13 +50,13 @@ typedef struct {
51
50
int maxlevels ;
52
51
} skiplist_t ;
53
52
54
- PANDAS_INLINE double urand (void ) {
53
+ static inline double urand (void ) {
55
54
return ((double )rand () + 1 ) / ((double )RAND_MAX + 2 );
56
55
}
57
56
58
- PANDAS_INLINE int int_min (int a , int b ) { return a < b ? a : b ; }
57
+ static inline int int_min (int a , int b ) { return a < b ? a : b ; }
59
58
60
- PANDAS_INLINE node_t * node_init (double value , int levels ) {
59
+ static inline node_t * node_init (double value , int levels ) {
61
60
node_t * result ;
62
61
result = (node_t * )malloc (sizeof (node_t ));
63
62
if (result ) {
@@ -78,9 +77,9 @@ PANDAS_INLINE node_t *node_init(double value, int levels) {
78
77
}
79
78
80
79
// do this ourselves
81
- PANDAS_INLINE void node_incref (node_t * node ) { ++ (node -> ref_count ); }
80
+ static inline void node_incref (node_t * node ) { ++ (node -> ref_count ); }
82
81
83
- PANDAS_INLINE void node_decref (node_t * node ) { -- (node -> ref_count ); }
82
+ static inline void node_decref (node_t * node ) { -- (node -> ref_count ); }
84
83
85
84
static void node_destroy (node_t * node ) {
86
85
int i ;
@@ -100,7 +99,7 @@ static void node_destroy(node_t *node) {
100
99
}
101
100
}
102
101
103
- PANDAS_INLINE void skiplist_destroy (skiplist_t * skp ) {
102
+ static inline void skiplist_destroy (skiplist_t * skp ) {
104
103
if (skp ) {
105
104
node_destroy (skp -> head );
106
105
free (skp -> tmp_steps );
@@ -109,7 +108,7 @@ PANDAS_INLINE void skiplist_destroy(skiplist_t *skp) {
109
108
}
110
109
}
111
110
112
- PANDAS_INLINE skiplist_t * skiplist_init (int expected_size ) {
111
+ static inline skiplist_t * skiplist_init (int expected_size ) {
113
112
skiplist_t * result ;
114
113
node_t * NIL , * head ;
115
114
int maxlevels , i ;
@@ -147,7 +146,7 @@ PANDAS_INLINE skiplist_t *skiplist_init(int expected_size) {
147
146
}
148
147
149
148
// 1 if left < right, 0 if left == right, -1 if left > right
150
- PANDAS_INLINE int _node_cmp (node_t * node , double value ) {
149
+ static inline int _node_cmp (node_t * node , double value ) {
151
150
if (node -> is_nil || node -> value > value ) {
152
151
return -1 ;
153
152
} else if (node -> value < value ) {
@@ -157,7 +156,7 @@ PANDAS_INLINE int _node_cmp(node_t *node, double value) {
157
156
}
158
157
}
159
158
160
- PANDAS_INLINE double skiplist_get (skiplist_t * skp , int i , int * ret ) {
159
+ static inline double skiplist_get (skiplist_t * skp , int i , int * ret ) {
161
160
node_t * node ;
162
161
int level ;
163
162
@@ -181,7 +180,7 @@ PANDAS_INLINE double skiplist_get(skiplist_t *skp, int i, int *ret) {
181
180
182
181
// Returns the lowest rank of all elements with value `value`, as opposed to the
183
182
// highest rank returned by `skiplist_insert`.
184
- PANDAS_INLINE int skiplist_min_rank (skiplist_t * skp , double value ) {
183
+ static inline int skiplist_min_rank (skiplist_t * skp , double value ) {
185
184
node_t * node ;
186
185
int level , rank = 0 ;
187
186
@@ -199,7 +198,7 @@ PANDAS_INLINE int skiplist_min_rank(skiplist_t *skp, double value) {
199
198
// Returns the rank of the inserted element. When there are duplicates,
200
199
// `rank` is the highest of the group, i.e. the 'max' method of
201
200
// https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.rank.html
202
- PANDAS_INLINE int skiplist_insert (skiplist_t * skp , double value ) {
201
+ static inline int skiplist_insert (skiplist_t * skp , double value ) {
203
202
node_t * node , * prevnode , * newnode , * next_at_level ;
204
203
int * steps_at_level ;
205
204
int size , steps , level , rank = 0 ;
@@ -253,7 +252,7 @@ PANDAS_INLINE int skiplist_insert(skiplist_t *skp, double value) {
253
252
return rank + 1 ;
254
253
}
255
254
256
- PANDAS_INLINE int skiplist_remove (skiplist_t * skp , double value ) {
255
+ static inline int skiplist_remove (skiplist_t * skp , double value ) {
257
256
int level , size ;
258
257
node_t * node , * prevnode , * tmpnode , * next_at_level ;
259
258
node_t * * chain ;
0 commit comments