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;
}
|