344 //------------------------------Key Comparator Functions--------------------- |
344 //------------------------------Key Comparator Functions--------------------- |
345 int32 cmpstr(const void *k1, const void *k2) { |
345 int32 cmpstr(const void *k1, const void *k2) { |
346 return strcmp((const char *)k1,(const char *)k2); |
346 return strcmp((const char *)k1,(const char *)k2); |
347 } |
347 } |
348 |
348 |
349 // Slimey cheap key comparator. |
349 // Cheap key comparator. |
350 int32 cmpkey(const void *key1, const void *key2) { |
350 int32 cmpkey(const void *key1, const void *key2) { |
351 return (int32)((intptr_t)key1 - (intptr_t)key2); |
351 if (key1 == key2) return 0; |
|
352 intptr_t delta = (intptr_t)key1 - (intptr_t)key2; |
|
353 if (delta > 0) return 1; |
|
354 return -1; |
352 } |
355 } |
353 |
356 |
354 //============================================================================= |
357 //============================================================================= |
355 //------------------------------reset------------------------------------------ |
358 //------------------------------reset------------------------------------------ |
356 // Create an iterator and initialize the first variables. |
359 // Create an iterator and initialize the first variables. |