source: branches/stable/CORE/arb_sort.cxx

Last change on this file was 8607, checked in by westram, 7 years ago

merge from e4fix [8135] [8136] [8137] [8138] [8139] [8140] [8141] [8142] [8143] [8144] [8222]
(this revives the reverted patches [8129] [8130] [8131] [8132]; see [8133])

  • fixes
    • some free/delete mismatches
    • wrong definition of ORF objects (Level was no bit value)
    • amino consensus (failed for columns only containing 'C')
  • rename
    • AA_sequence_term → orf_term
    • ED4_sequence_terminal_basic → ED4_abstract_sequence_terminal
  • cleaned up hierarchy dumps
  • tweaked is_terminal()/to_terminal()
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : arb_sort.cxx                                      //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include "arb_sort.h"
12#include <cstring>
13
14
15struct comparator {
16    gb_compare_function  compare;
17    void                *client_data;
18};
19
20static comparator Compare; // current compare function + client data
21
22static int qsort_compare(const void *v1, const void *v2) {
23    return Compare.compare(*(void**)v1, *(void**)v2, Compare.client_data);
24}
25
26void GB_sort(void **array, size_t first, size_t behind_last, gb_compare_function compare, void *client_data) {
27    /* sort 'array' of pointers from 'first' to last element
28     * (specified by following element 'behind_last')
29     * 'compare' is a compare function, with a strcmp-like result value
30     */
31
32    Compare.compare     = compare;
33    Compare.client_data = client_data;
34
35    qsort(array, behind_last-first, sizeof(*array), qsort_compare);
36}
37
38// --------------------------
39//      some comparators
40
41int GB_string_comparator(const void *v0, const void *v1, void */*unused*/) {
42    return strcmp((const char *)v0, (const char *)v1);
43}
44
Note: See TracBrowser for help on using the repository browser.