void AccountMap::Find( const ID& id, const class Account* account ) { SkipListNode* node = Next(ninf); size_t i = id.find_first_of("?*"); string id_key; bool key_not_used = true; if (i == string::npos) { id_key = id; key_not_used = false; if(!Find(id_key, node)) node = Next(node); } else if (i > 0) { id_key = id.substr(0, i); key_not_used = false; if(!Find(id_key, node)) node = Next(node); } bool comma = false; while (node->data_id.front() != '{' && (key_not_used || \ node->data_id.compare(0, i, id_key) == 0)) { if (match_recursion(id, node->data_id, 0, 0) && \ account != node->data_account) { if (comma) { cout << ','; } cout << node->data_id; comma = true; } node = Next(node); } }
void AccountMap::Unused( const ID& id ) { int target_score = 1; int len = id.size(); int min_len = len - 1; int max_len = (len+1 < 100) ? (len+1):100; int output = 0; bool comma = false; SkipListNode* temp; string test; if (min_len == 0) { test = "0"; } else { test = id.substr(0, min_len); } while (output < 10) { if (calculate_score(test, id) == target_score && !Find(test, temp)) { if (comma) { cout << ','; } cout << test; comma = true; output += 1; } if (!next_string(test, min_len, max_len)) { target_score += 1; min_len = (min_len == 0) ? 0:(min_len-1); if (max_len != 100 && (max_len+1-len+1)*(max_len+1-len)/2 <= target_score) { max_len += 1; } if (min_len == 0) { test = "0"; } else { test = id.substr(0, min_len); } } } }