/** * Add an element to the heap conditionally: * (1) Add the element if we are not on full capacity. * (2) If we are on full capacity, add the element only after comparison. */ bool add (const value_type& value) { if (size<K) { heap.push(value); ++size; return true; } else if (false==compare(heap.top(),value)) { heap.pop (); heap.push (value); return true; } else { return false; } }
static void similar_row_one( const bit_vector& x, const pair<string, bit_vector>& y, heap_type& heap) { uint64_t match_num = x.calc_hamming_similarity(y.second); heap.push(make_pair(match_num, y.first)); }