File: comparators.cpp

package info (click to toggle)
drbd-utils 9.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,388 kB
  • sloc: ansic: 43,698; xml: 15,968; cpp: 7,783; sh: 3,699; makefile: 1,353; perl: 353
file content (46 lines) | stat: -rw-r--r-- 719 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
#include <comparators.h>

int comparators::compare_uint16(const uint16_t* key_ptr, const uint16_t* other_ptr)
{
    int rc = 0;

    int key = *key_ptr;
    int other = *other_ptr;

    if (key < other)
    {
        rc = -1;
    }
    else
    if (key > other)
    {
        rc = 1;
    }

    return rc;
}

int comparators::compare_string(const std::string* key_ptr, const std::string* other_ptr)
{
    return key_ptr->compare(*other_ptr);
}

int comparators::compare_char(const char* key_ptr, const char* other_ptr)
{
    int rc = 0;

    char key = *key_ptr;
    char other = *other_ptr;

    if (key < other)
    {
        rc = -1;
    }
    else
    if (key > other)
    {
        rc = 1;
    }

    return rc;
}