File: funCompareUintAndSuffixes.cpp

package info (click to toggle)
rna-star 2.7.8a%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,076 kB
  • sloc: cpp: 20,429; awk: 483; ansic: 470; makefile: 181; sh: 31
file content (40 lines) | stat: -rw-r--r-- 1,338 bytes parent folder | download | duplicates (6)
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
37
38
39
40
#include "funCompareUintAndSuffixes.h"

char* g_funCompareUintAndSuffixes_G;
uint64_t g_funCompareUintAndSuffixes_L;

int funCompareUintAndSuffixes ( const void *a, const void *b){
    uint64_t* va= ((uint64_t*) a);
    uint64_t* vb= ((uint64_t*) b);

    if (va[0]>vb[0]) {
            return 1;
        } else if (va[0]<vb[0]) {
            return -1;
        } else {//compare suffixes
            char* ga=g_funCompareUintAndSuffixes_G + *( ((uint64_t*) a)+1);
            char* gb=g_funCompareUintAndSuffixes_G + *( ((uint64_t*) b)+1);
            int ig=0;
            while (true) {
                if (ga[ig]>gb[ig])
                {// second condition: reached the end of ga, it's >= than any character, but = does not matter
                    return 1;
                } else if (ga[ig]<gb[ig])
                {
                    return -1;
                } else if (ga[ig]==5)
                {//reached the end of chr, now simply compare the indexes for stable search
                    if (va[1]>vb[1])
                    {
                        return 1;
                    } else
                    {//va cannot be equal to vb
                        return -1;
                    };
                } else
                {//continue
                    ig++;
                };
            };
        };
};