int cnt=0;
for (int i=0; i < relevant_items.size(); ++i){
int item_id=relevant_items.get(i);
if(consumedItems.contains(item_id)==false){
WeightedItem wi = new WeightedItem(item_id, recommender.Predict(user_id, item_id));
pq.add(wi);
cnt++;
if(cnt==topk)
break;
}
}
double minScore = pq.element().weight;
for(int i1 = topk; i1 < relevant_items.size(); i1++){
int item_id=relevant_items.get(i1);
WeightedItem wi = new WeightedItem(item_id, recommender.Predict(user_id, item_id));
if (wi.weight < minScore){
continue;
// This item is not candidate for topk items
}