Example #1
0
 @Override
 public int compareTo(final EntryValue other) {
   final Comparable<?> otherValue = other.getValue();
   if (otherValue instanceof String) {
     return value.compareTo((String) otherValue);
   } else {
     throw new RuntimeException("Can't compare different EntryValue types");
   }
 }
Example #2
0
  protected int addEntry(EntryValue e) {
    assert !frozen;
    Integer idx = (Integer) entryToIndex.get(e);
    if (idx != null) return idx.intValue();

    e.addChildren();

    int index = currIndex;
    currIndex += e.getSize();

    entryToIndex.put(e, new Integer(index));
    if (index >= indexToEntry.length) {
      Entry[] newI2E = new Entry[indexToEntry.length * 2];
      System.arraycopy(indexToEntry, 0, newI2E, 0, indexToEntry.length);
      indexToEntry = newI2E;
    }
    indexToEntry[index] = e;
    return index;
  }