prune(items);
if (!removedOldItem) { totalItems++; }  if (item.logProb() > chart[start][end].topLogProb) chart[start][end].topLogProb = item.logProb(); }  if (debugAddToChart) { if (itemExists) { if (itemProb.doubleValue() < item.logProb()) { System.err.println(className + ": adding item because equivalent " + "item exists with lower prob; existing item " + "prob=" + itemProb + "; item to add prob=" + item.logProb()); } else if (itemProb.doubleValue() == item.logProb()) { System.err.println(className + ": not adding item because " + "equivalent item exists with " + "equal prob; prob=" + itemProb); System.err.println("\titem that was to be added(" + start + "," + end + "): " + item); } else { System.err.println(className + ": not adding item because " + "equivalent item exists with higher prob; " + "existing item prob=" + itemProb + "; item to add prob=" + item.logProb()); System.err.println("\titem that was to be added(" + start + "," + end + "): " + item); } } }
  public void add(int start, int end, Item item) {    Map map = chart[start][end];    Object label = item.label();    SortedMap items = (SortedMap)map.get(label);    if (items == null) {      items = new TreeMap();      map.put(label, items);      items.put(item, new Double(item.logProb()));    }    else if (!toPrune(items, item)) {      // see if equal (technically, equivalent) item already exists      // but has a lower probability, replace it with current item      Double itemProb = (Double)items.get(item);      if (itemProb == null ||          (itemProb != null && itemProb.doubleValue() < item.logProb()))	items.put(item, new Double(item.logProb()));      prune(items);    }  }