1
0
forked from GitHub/gf-core

added order and equality for strings in libgu

This commit is contained in:
kr.angelov
2013-09-17 13:45:37 +00:00
parent 2a49e4e1d6
commit d1e6a9c2ba
2 changed files with 35 additions and 15 deletions

View File

@@ -421,6 +421,17 @@ gu_string_eq(GuString s1, GuString s2)
}
static bool
gu_string_eq_fn(GuEquality* self, const void* p1, const void* p2)
{
(void) self;
const GuString* sp1 = p1;
const GuString* sp2 = p2;
return gu_string_eq(*sp1, *sp2);
}
GuEquality gu_string_equality[1] = { { gu_string_eq_fn } };
int
gu_string_cmp(GuString s1, GuString s2)
{
@@ -478,6 +489,17 @@ gu_string_cmp(GuString s1, GuString s2)
return 0;
}
static int
gu_string_cmp_fn(GuOrder* self, const void* p1, const void* p2)
{
(void) self;
const GuString* sp1 = p1;
const GuString* sp2 = p2;
return gu_string_cmp(*sp1, *sp2);
}
GuOrder gu_string_order[1] = { { gu_string_cmp_fn } };
static GuHash
gu_string_hasher_hash(GuHasher* self, const void* p)
{
@@ -486,15 +508,6 @@ gu_string_hasher_hash(GuHasher* self, const void* p)
return gu_string_hash(0, *sp);
}
static bool
gu_string_eq_fn(GuEquality* self, const void* p1, const void* p2)
{
(void) self;
const GuString* sp1 = p1;
const GuString* sp2 = p2;
return gu_string_eq(*sp1, *sp2);
}
GuHasher gu_string_hasher[1] = {
{
.eq = { gu_string_eq_fn },