/* * check_util.h * * Created on: Jan 25, 2010 * Author: sears */ #ifndef CHECK_UTIL_H_ #define CHECK_UTIL_H_ #include #include #include bool mycmp(const std::string & k1,const std::string & k2) { //for char* ending with \0 return strcmp(k1.c_str(),k2.c_str()) < 0; //for int32_t //printf("%d\t%d\n",(*((int32_t*)k1)) ,(*((int32_t*)k2))); //return (*((int32_t*)k1)) <= (*((int32_t*)k2)); } //must be given a sorted array void removeduplicates(std::vector *arr) { for(int i=arr->size()-1; i>0; i--) { if(! (mycmp((*arr)[i], (*arr)[i-1]) || mycmp((*arr)[i-1], (*arr)[i]))) arr->erase(arr->begin()+i); } } //must be given a sorted array // XXX probably don't need two copies of this function. void removeduplicates(std::vector &arr) { for(int i=arr.size()-1; i>0; i--) { if(! (mycmp(arr[i], arr[i-1]) || mycmp(arr[i-1], arr[i]))) arr.erase(arr.begin()+i); } } void getnextdata(std::string &data, int avg_len) { int str_len = (rand()%(avg_len*2)) + 3; data = std::string(str_len, rand()%10+48); /* char *rc = (char*)malloc(str_len); for(int i=0; i *arr, int avg_len=50, bool duplicates_allowed=false) { for ( int j=0; jpush_back(str); } } void preprandstr(int count, std::vector &arr, int avg_len=50, bool duplicates_allowed=false) { for ( int j=0; j