cleanup: prefer List#sort over Collections#sort

This commit is contained in:
P0nk
2021-04-08 07:44:02 +02:00
parent 5730b3b42d
commit ebb3aa7ba3
14 changed files with 28 additions and 24 deletions

View File

@@ -451,7 +451,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
timedBuffs.add(new Pair<>(curtime - pb.usedTime, pb));
}
Collections.sort(timedBuffs, (p1, p2) -> p1.getLeft().compareTo(p2.getLeft()));
timedBuffs.sort((p1, p2) -> p1.getLeft().compareTo(p2.getLeft()));
return timedBuffs;
}

View File

@@ -82,7 +82,7 @@ public class PartySearchStorage {
pscList.add(new PartySearchCharacter(chr));
}
Collections.sort(pscList, (c1, c2) -> {
pscList.sort((c1, c2) -> {
int levelP1 = c1.getLevel(), levelP2 = c2.getLevel();
return levelP1 > levelP2 ? 1 : (levelP1 == levelP2 ? 0 : -1);
});

View File

@@ -579,7 +579,7 @@ public class MapleSessionCoordinator {
public void printSessionTrace() {
if (!onlineClients.isEmpty()) {
List<Entry<Integer, MapleClient>> elist = new ArrayList<>(onlineClients.entrySet());
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
System.out.println("Current online clients: ");
for (Entry<Integer, MapleClient> e : elist) {
@@ -600,7 +600,7 @@ public class MapleSessionCoordinator {
if (!loginRemoteHosts.isEmpty()) {
List<Entry<String, Set<IoSession>>> elist = new ArrayList<>(loginRemoteHosts.entrySet());
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
System.out.println("Current login sessions: ");
for (Entry<String, Set<IoSession>> e : elist) {
@@ -614,7 +614,7 @@ public class MapleSessionCoordinator {
if (!onlineClients.isEmpty()) {
List<Entry<Integer, MapleClient>> elist = new ArrayList<>(onlineClients.entrySet());
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
str += ("Current online clients:\r\n");
for (Entry<Integer, MapleClient> e : elist) {
@@ -635,7 +635,7 @@ public class MapleSessionCoordinator {
if (!loginRemoteHosts.isEmpty()) {
List<Entry<String, Set<IoSession>>> elist = new ArrayList<>(loginRemoteHosts.entrySet());
Collections.sort(elist, (e1, e2) -> e1.getKey().compareTo(e2.getKey()));
elist.sort((e1, e2) -> e1.getKey().compareTo(e2.getKey()));
str += ("Current login sessions:\r\n");
for (Entry<String, Set<IoSession>> e : elist) {

View File

@@ -234,7 +234,7 @@ public class MapleMonsterAggroCoordinator {
if (!toRemoveIdx.isEmpty()) {
// last to first indexes
Collections.sort(toRemoveIdx, (p1, p2) -> p1 < p2 ? 1 : p1.equals(p2) ? 0 : -1);
toRemoveIdx.sort((p1, p2) -> p1 < p2 ? 1 : p1.equals(p2) ? 0 : -1);
for (int idx : toRemoveIdx) {
sortedAggro.remove(idx);

View File

@@ -211,7 +211,7 @@ public class MapleParty {
lock.unlock();
}
Collections.sort(histList, (o1, o2) -> (o1.getValue()).compareTo(o2.getValue()));
histList.sort((o1, o2) -> (o1.getValue()).compareTo(o2.getValue()));
List<Integer> histSort = new LinkedList<>();
for (Entry<Integer, Integer> e : histList) {

View File

@@ -461,7 +461,7 @@ public class World {
list.add(e);
}
Collections.sort(list, (o1, o2) -> o1.getKey() - o2.getKey());
list.sort((o1, o2) -> o1.getKey() - o2.getKey());
return list;
}
@@ -1844,7 +1844,7 @@ public class World {
}
}
Collections.sort(hmsAvailable, (p1, p2) -> p1.getLeft().getPrice() - p2.getLeft().getPrice());
hmsAvailable.sort((p1, p2) -> p1.getLeft().getPrice() - p2.getLeft().getPrice());
hmsAvailable.subList(0, Math.min(hmsAvailable.size(), 200)); //truncates the list to have up to 200 elements
return hmsAvailable;