/*
 *  BSD License (http://www.galagosearch.org/license)
 */
package org.lemurproject.galago.core.eval;

import javax.annotation.Nonnull;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

/**
 * Stores a list of returned ScoredDocuments for a query.
 *
 * @author sjh
 */
public class QueryResults extends AbstractList<EvalDoc> {

  private String query;
  private List<EvalDoc> rankedList;

  public QueryResults(@Nonnull List<? extends EvalDoc> rankedList) {
    this("unknown-id", rankedList);
  }
  public QueryResults(String query, @Nonnull List<? extends EvalDoc> rankedList) {
    this.query = query;
    this.rankedList = new ArrayList<>(rankedList);
  }

  @Nonnull
  public Iterable<EvalDoc> getIterator() {
    return rankedList;
  }

  @Override
  public int size() {
    return rankedList.size();
  }

  @Override
  public EvalDoc get(int index) {
    return rankedList.get(index);
  }
}

@@ -131,16 +131,50 @@
 onnull;%0A
+import javax.annotation.Nullable;%0A
 import j
@@ -958,11 +958,540 @@
 ex);%0A  %7D
+%0A%0A  @Nullable%0A  public EvalDoc find(String docId) %7B%0A    for (EvalDoc evalDoc : this) %7B%0A      if(evalDoc.getName().equals(docId)) %7B%0A        return evalDoc;%0A      %7D%0A    %7D%0A    return null;%0A  %7D%0A%0A  /**%0A   * Returns the score for the given document id or a default value.%0A   * @param docId%0A   * @param backup%0A   * @return%0A   */%0A  public double findScore(String docId, double backup) %7B%0A    for (EvalDoc evalDoc : this) %7B%0A      if(evalDoc.getName().equals(docId)) %7B%0A        return evalDoc.getScore();%0A      %7D%0A    %7D%0A    return backup;%0A  %7D
 %0A%7D%0A

add find helpers to QueryResults