/********************************************************* * @name: ComparatorC * @func: use to find a smaller data in compact... * @in: const data_t*, const data_t* * @ret: int *********************************************************/ int ComparatorC( const data_t* first, const data_t* second ) { int ret; if (first == NULL && second == NULL) { return 0; } else if(first == NULL && second != NULL)//in my opinion : NULL data -the data is smaller { return 1; } else if(first != NULL && second == NULL) { return -1; } if (first->hash_value > second->hash_value) { ret = 1; } else if (first->hash_value == second->hash_value) { ret = CmpKey(first->key, first->key_len, second->key, second->key_len); } else { ret = -1; } return ret; }
int ComparatorB( unsigned long firsthash, const char* firstkey, unsigned long secondhash, const char* secondkey ) { int ret; if (firsthash > secondhash) { ret = 1; } else if (firsthash == secondhash) { ret = CmpKey(firstkey, strlen(firstkey), secondkey, strlen(secondkey)); } else { ret = -1; } return ret; }
int Comparator( const data_t first, const data_t second ) { int ret; if (first.hash_value > second.hash_value) { ret = 1; } else if (first.hash_value == second.hash_value) { ret = CmpKey(first.key, first.key_len, second.key, second.key_len); } else { ret = -1; } return ret; }
void sort_by_key(pcooc_vector_t * vec,unsigned long mem) { // cout<<"Using memory block: "<<mem/1024/1024<<endl; pvectors::sort(vec/*->begin(),vec->end()*/,CmpKey(),mem); }