public static void removeDupes(
      final List<CharSequence> suggestions, List<CharSequence> stringsPool) {
    if (suggestions.size() < 2) return;
    int i = 1;
    // Don't cache suggestions.size(), since we may be removing items
    while (i < suggestions.size()) {
      final CharSequence cur = suggestions.get(i);
      // Compare each suggestion with each previous suggestion
      for (int j = 0; j < i; j++) {
        CharSequence previous = suggestions.get(j);
        if (TextUtils.equals(cur, previous)) {
          removeSuggestion(suggestions, i, stringsPool);
          i--;
          break;
        }
      }
      i++;
    }
  }
@Test
  public void testRemoveDupesDupeIsNotFirst() throws Exception {
    ArrayList<CharSequence> list =
        new ArrayList<>(
            Arrays.<CharSequence>asList("typed", "something", "duped", "duped", "something"));
    IMEUtil.removeDupes(list, mStringPool);
    Assert.assertEquals(3, list.size());
    Assert.assertEquals("typed", list.get(0));
    Assert.assertEquals("something", list.get(1));
    Assert.assertEquals("duped", list.get(2));
  }