示例#1
0
 @SuppressWarnings("unchecked")
 public T next() {
   IteratorNode ctx = (IteratorNode) _queue.top();
   T val = ctx._curVal;
   if (ctx.fetch()) {
     _queue.updateTop();
   } else {
     _queue.pop();
   }
   return val;
 }
示例#2
0
 private void updateTop(
     CandidateSet[] candidates,
     Candidate[] path,
     PriorityQueue<Correction> corrections,
     double cutoffScore,
     double score)
     throws IOException {
   score = Math.exp(score);
   assert Math.abs(score - score(path, candidates)) < 0.00001;
   if (score > cutoffScore) {
     if (corrections.size() < maxNumCorrections) {
       Candidate[] c = new Candidate[candidates.length];
       System.arraycopy(path, 0, c, 0, path.length);
       corrections.add(new Correction(score, c));
     } else if (corrections.top().compareTo(score, path) < 0) {
       Correction top = corrections.top();
       System.arraycopy(path, 0, top.candidates, 0, path.length);
       top.score = score;
       corrections.updateTop();
     }
   }
 }