X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FIndexBuilder.java;h=680cf4adc5dee305793dced0a21c5b4be27ed0a8;hb=2fc669d88306d563fc9c899d8d91b25d591692ea;hp=e7e1b43635627d146d263dbf0c5a6ea5d85b1570;hpb=e479ba38bbcb261951399326623c20ffacc147d4;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/engine/IndexBuilder.java b/src/com/hughes/android/dictionary/engine/IndexBuilder.java index e7e1b43..680cf4a 100644 --- a/src/com/hughes/android/dictionary/engine/IndexBuilder.java +++ b/src/com/hughes/android/dictionary/engine/IndexBuilder.java @@ -39,12 +39,12 @@ public class IndexBuilder { IndexBuilder(final DictionaryBuilder dictionaryBuilder, final String shortName, final String longName, final Language language, final String normalizerRules, final Set stoplist, final boolean swapPairEntries) { this.dictionaryBuilder = dictionaryBuilder; index = new Index(dictionaryBuilder.dictionary, shortName, longName, language, normalizerRules, swapPairEntries, stoplist); - tokenToData = new TreeMap(index.getSortComparator()); + tokenToData = new TreeMap<>(index.getSortComparator()); this.stoplist = stoplist; } public void build() { - final Set tokenIndexedEntries = new HashSet(); + final Set tokenIndexedEntries = new HashSet<>(); final List rows = index.rows; index.mainTokenCount = 0; for (final TokenData tokenData : tokenToData.values()) { @@ -101,13 +101,8 @@ public class IndexBuilder { } } - final List entriesSortedByNumRows = new ArrayList(index.sortedIndexEntries); - Collections.sort(entriesSortedByNumRows, new Comparator() { - @Override - public int compare(IndexEntry object1, IndexEntry object2) { - return object2.numRows - object1.numRows; - } - }); + final List entriesSortedByNumRows = new ArrayList<>(index.sortedIndexEntries); + entriesSortedByNumRows.sort((object1, object2) -> object2.numRows - object1.numRows); System.out.println("Most common tokens:"); for (int i = 0; i < 50 && i < entriesSortedByNumRows.size(); ++i) { System.out.println(" " + entriesSortedByNumRows.get(i)); @@ -117,10 +112,10 @@ public class IndexBuilder { public static class TokenData { final String token; - final Map> typeToEntries = new EnumMap>(EntryTypeName.class); + final Map> typeToEntries = new EnumMap<>(EntryTypeName.class); public boolean hasMainEntry = false; - public List htmlEntries = new ArrayList(); + public final List htmlEntries = new ArrayList<>(); TokenData(final String token) { assert token.equals(token.trim()); @@ -145,7 +140,7 @@ public class IndexBuilder { tokenData.hasMainEntry = true; } if (entries == null) { - entries = new ArrayList(); + entries = new ArrayList<>(); tokenData.typeToEntries.put(entryTypeName, entries); } return entries;