Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void addFiles(Path directory) throws InterruptedException {
if (crawlOrder == CRAWL_ORDER.RANDOM) {
Collections.shuffle(files);
} else if (crawlOrder == CRAWL_ORDER.SORTED) {
Collections.sort(files, pathComparator);
files.sort(pathComparator);
}

int numFiles = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,7 @@ public Entry firstEntry() {
private List<Map.Entry<String, Counter>> getSortedNgrams() {
List<Map.Entry<String, Counter>> entries = new ArrayList<Map.Entry<String, Counter>>(ngrams.size());
entries.addAll(ngrams.entrySet());
Collections.sort(entries, new Comparator<Map.Entry<String, Counter>>() {
@Override
public int compare(Map.Entry<String, Counter> o1, Map.Entry<String, Counter> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
entries.sort(Map.Entry.comparingByKey());
return entries;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,7 @@ void unicodeBlocks(Map<Class, Object> tokenStats, Map<Cols, String> data) {
for (Map.Entry<String, MutableInt> e : blocks.entrySet()) {
pairs.add(Pair.of(e.getKey(), e.getValue().intValue()));
}
Collections.sort(pairs, new Comparator<Pair<String, Integer>>() {
@Override
public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) {
return o2.getValue().compareTo(o1.getValue());
}
});
pairs.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
StringBuilder sb = new StringBuilder();

for (int i = 0; i < 20 && i < pairs.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String calculate(TokenCounts tokenCounts) {
profile.add(new Token((e.getValue().intValue() / quant) * quant, e.getKey()));
}
}
Collections.sort(profile, new TokenComparator());
profile.sort(new TokenComparator());
StringBuffer newText = new StringBuffer();
int i = 0;
for (Token t : profile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ public void rollback(File deployArea) throws IOException, SAXException,
List<Link> links = handler.getLinks();
if (links.size() < 2)
throw new IOException("Must have installed at least 2 versions!");
Collections.sort(links, new Comparator<Link>() {
public int compare(Link o1, Link o2) {
return o1.getText().compareTo(o2.getText());
}
});
links.sort(Comparator.comparing(Link::getText));

this.updateVersion(links.get(links.size() - 2).getText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private List<FieldInfo> getSortedFieldInfoList(InputStream stream, short numEntr
throw new TikaException("AppleSingleFile missing field info");
}
//make absolutely sure these are in order!
Collections.sort(fieldInfoList, new FieldInfoComparator());
fieldInfoList.sort(Comparator.comparingLong(fieldInfo -> fieldInfo.offset));
return fieldInfoList;
}

Expand Down Expand Up @@ -189,14 +189,4 @@ private FieldInfo(long entryId, long offset, long length) {
this.length = length;
}
}

private static class FieldInfoComparator implements Comparator<FieldInfo> {

@Override
public int compare(FieldInfo o1, FieldInfo o2) {
return (o1.offset > o2.offset) ? 1 :
(o1.offset == o2.offset) ? 0 : -1 ;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private List<List<GlyphRun>> buildRows(List<GlyphRun> glyphRuns) {
//in most xps files in our test corpus, this is never triggered
//because the runs are already ordered correctly
if (maxY > -1.0f && addedNewRow && glyphRun.originY < maxY) {
Collections.sort(rows, ROW_SORTER);
rows.sort(ROW_SORTER);
}
if (glyphRun.originY > maxY) {
maxY = glyphRun.originY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ public class ObjectRecognitionParser extends AbstractParser implements Initializ
public static final String MD_KEY_IMG_CAP = "CAPTION";
public static final String MD_REC_IMPL_KEY =
ObjectRecognitionParser.class.getPackage().getName() + ".object.rec.impl";
private static final Comparator<RecognisedObject> DESC_CONFIDENCE_SORTER =
new Comparator<RecognisedObject>() {
@Override
public int compare(RecognisedObject o1, RecognisedObject o2) {
return Double.compare(o2.getConfidence(), o1.getConfidence());
}
};

private ObjectRecogniser recogniser;

Expand Down Expand Up @@ -126,7 +119,7 @@ public synchronized void parse(InputStream stream, ContentHandler handler, Metad
List<String> xhtmlIds = new ArrayList<String>();
String xhtmlStartVal = null;
count = 0;
Collections.sort(objects, DESC_CONFIDENCE_SORTER);
objects.sort((o1, o2) -> Double.compare(o2.getConfidence(), o1.getConfidence()));
// first process all the MD objects
for (RecognisedObject object : objects) {
if (object instanceof CaptionObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,9 @@ public void getBestNameEntity() {
tf.put(this.locationNameEntities.get(i), 1);
}
int max = 0;
List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(
tf.entrySet());
List<Map.Entry<String, Integer>> list = new ArrayList<>(tf.entrySet());
Collections.shuffle(list);
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
public int compare(Map.Entry<String, Integer> o1,
Map.Entry<String, Integer> o2) {
// Descending Order
return o2.getValue().compareTo(o1.getValue());
}
});
list.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));

this.locationNameEntities.clear();// update so that they are in
// descending order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,7 @@ private ParserDetails(Parser p) {
((CompositeParser) p).getParsers(EMPTY_PC).values());
// Sort it by class name
childParsers = new ArrayList<Parser>(children);
Collections.sort(childParsers, new Comparator<Parser>() { @Override
public int compare(Parser p1, Parser p2) {
return p1.getClass().getName().compareTo(p2.getClass().getName());
}
});
childParsers.sort(Comparator.comparing(parser -> parser.getClass().getName()));
} else {
supportedTypes = p.getSupportedTypes(EMPTY_PC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected List<Endpoint> identifyEndpoints() {
}
}
}
Collections.sort(found, new Comparator<Endpoint>() {
found.sort(new Comparator<Endpoint>() {
@Override
public int compare(Endpoint e1, Endpoint e2) {
int res = e1.path.compareTo(e2.path);
Expand Down