@@ -0,0 +1,1390 @@
+package sssj.base;%0A%0Aimport it.unimi.dsi.fastutil.longs.Long2ReferenceLinkedOpenHashMap;%0Aimport it.unimi.dsi.fastutil.longs.Long2ReferenceMap.Entry;%0A%0Aimport java.util.Iterator;%0A%0Apublic class StreamingResidualList implements Iterable%3CVector%3E %7B%0A  private Long2ReferenceLinkedOpenHashMap%3CVector%3E map = new Long2ReferenceLinkedOpenHashMap%3C%3E();%0A%0A  public void add(Vector residual) %7B%0A    map.put(residual.timestamp(), residual);%0A  %7D%0A%0A  @Override%0A  public Iterator%3CVector%3E iterator() %7B%0A    return map.values().iterator();%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return %22ResidualList = %5B%22 + map + %22%5D%22;%0A  %7D%0A%0A  public Vector get(long candidateID) %7B%0A    return map.get(candidateID);%0A  %7D%0A%0A  /**%0A   * Get the residual of the vector with id %7B@code candidateID%7D, while at the same time pruning all the residuals with timestamp less than %7B@code lowWatermark%7D.%0A   *%0A   * @param candidateID the id of the candidate vector%0A   * @param lowWatermark the minimum id of the vector to be retained%0A   * @return the residual of the candidate%0A   */%0A  public Vector getAndPrune(long candidateID, long lowWatermark) %7B%0A    for (Iterator%3CEntry%3CVector%3E%3E it = map.long2ReferenceEntrySet().fastIterator(); it.hasNext();) %7B%0A      final Vector v = it.next().getValue();%0A      if (lowWatermark %3E v.timestamp())%0A        it.remove();%0A      if (candidateID == v.timestamp())%0A        return v;%0A    %7D%0A    return null;%0A  %7D%0A%7D

Use hashmap for streaming residuals