diff options
-rw-r--r-- | docs/raptor-1-to-2-map.tsv | 1 | ||||
-rw-r--r-- | src/raptor2.h.in | 2 | ||||
-rw-r--r-- | src/raptor_sequence.c | 27 |
3 files changed, 29 insertions, 1 deletions
diff --git a/docs/raptor-1-to-2-map.tsv b/docs/raptor-1-to-2-map.tsv index 0ff01ebf..585ed123 100644 --- a/docs/raptor-1-to-2-map.tsv +++ b/docs/raptor-1-to-2-map.tsv @@ -427,6 +427,7 @@ 2.0.11 - - - 2.0.12 raptor_term* raptor_new_term_from_counted_string (raptor_world* world, unsigned char* string, size_t length) - 2.0.13 - - - 2.0.14 unsigned char* raptor_uri_counted_filename_to_uri_string (const char *filename, size_t filename_len) - 2.0.14 - - - 2.0.15 void raptor_sort_r (void *base, size_t nel, size_t width, raptor_sort_r_compare compar, void *user_data) - +2.0.14 - - - 2.0.15 void raptor_sequence_sort_r (raptor_sequence* seq, raptor_sort_r_compare compare, void* user_data) Uses raptor_sort_r() internally. # # Types # diff --git a/src/raptor2.h.in b/src/raptor2.h.in index 8a70c871..ed553445 100644 --- a/src/raptor2.h.in +++ b/src/raptor2.h.in @@ -1576,6 +1576,8 @@ void* raptor_sequence_delete_at(raptor_sequence* seq, int idx); RAPTOR_API void raptor_sequence_sort(raptor_sequence* seq, raptor_data_compare_handler compare); RAPTOR_API +void raptor_sequence_sort_r(raptor_sequence* seq, raptor_sort_r_compare compare, void* user_data); +RAPTOR_API int raptor_sequence_swap(raptor_sequence* seq, int i, int j); RAPTOR_API int raptor_sequence_reverse(raptor_sequence* seq, int start_index, int length); diff --git a/src/raptor_sequence.c b/src/raptor_sequence.c index 8943ec6a..8ad90417 100644 --- a/src/raptor_sequence.c +++ b/src/raptor_sequence.c @@ -517,7 +517,7 @@ raptor_sequence_unshift(raptor_sequence* seq) /** * raptor_sequence_sort: * @seq: sequence to sort - * @compare: comparison function + * @compare: comparison function with args (a, b) * * Sort a sequence inline * @@ -537,6 +537,31 @@ raptor_sequence_sort(raptor_sequence* seq, raptor_data_compare_handler compare) } +/** + * raptor_sequence_sort_r: + * @seq: sequence to sort + * @compare: comparison function with args (a, b, user data) + * @user_data: User data argument for @compare + * + * Sort a sequence inline with user data + * + * The comparison function @compare_r is compatible with that used + * for raptor_sort_r() and provides the addresses of pointers to the + * data that must be dereferenced to get to the stored sequence data. + * + **/ +RAPTOR_EXTERN_C +void +raptor_sequence_sort_r(raptor_sequence* seq, raptor_sort_r_compare compare, + void* user_data) +{ + RAPTOR_ASSERT_OBJECT_POINTER_RETURN(seq, raptor_sequence); + + if(seq->size > 1) + raptor_sort_r(&seq->sequence[seq->start], seq->size, sizeof(void*), + compare, user_data); +} + /** * raptor_sequence_print: |