314 //------------------------------Key Comparator Functions--------------------- |
314 //------------------------------Key Comparator Functions--------------------- |
315 int cmpstr(const void *k1, const void *k2) { |
315 int cmpstr(const void *k1, const void *k2) { |
316 return strcmp((const char *)k1,(const char *)k2); |
316 return strcmp((const char *)k1,(const char *)k2); |
317 } |
317 } |
318 |
318 |
319 // Slimey cheap key comparator. |
319 // Cheap key comparator. |
320 int cmpkey(const void *key1, const void *key2) { |
320 int cmpkey(const void *key1, const void *key2) { |
321 return (int)((intptr_t)key1 - (intptr_t)key2); |
321 if (key1 == key2) return 0; |
|
322 intptr_t delta = (intptr_t)key1 - (intptr_t)key2; |
|
323 if (delta > 0) return 1; |
|
324 return -1; |
322 } |
325 } |
323 |
326 |
324 //============================================================================= |
327 //============================================================================= |
325 //------------------------------reset------------------------------------------ |
328 //------------------------------reset------------------------------------------ |
326 // Create an iterator and initialize the first variables. |
329 // Create an iterator and initialize the first variables. |