MCPcopy Create free account
hub / github.com/e2wugui/zeze / sort

Method sort

ZezeJava/ZezeJava/src/main/java/Zeze/Game/Bag.java:282–298  ·  view source on GitHub ↗
(Comparator<Map.Entry<Integer, BItem>> comparison)

Source from the content-addressed store, hash-verified

280 }
281
282 public final void sort(Comparator<Map.Entry<Integer, BItem>> comparison) {
283 if (null == comparison)
284 comparison = Comparator.comparingLong(x -> x.getValue().getId());
285
286 @SuppressWarnings("unchecked")
287 var sort = (Map.Entry<Integer, BItem>[])bean.getItems().entrySet().toArray(new Map.Entry[bean.getItems().size()]);
288 Arrays.sort(sort, comparison);
289 for (int i = 0; i < sort.length; ++i) {
290 BItem copy = sort[i].getValue().copy();
291 sort[i] = Map.entry(i, copy); // old item IsManaged. need Copy a new one.
292 }
293 bean.getItems().clear();
294 var sortMap = new HashMap<Integer, BItem>();
295 for (var s : sort)
296 sortMap.put(s.getKey(), s.getValue());
297 bean.getItems().putAll(sortMap); // use AddRange for performance
298 }
299
300 public static class Module extends AbstractBag {
301 private final ConcurrentHashMap<String, Bag> bags = new ConcurrentHashMap<>();

Callers 15

onProcessMethod · 0.45
TasksClass · 0.45
testSortListMethod · 0.45
testSortedMapMethod · 0.45
testDiffMethod · 0.45
createRedirectModulesMethod · 0.45
tryCommitMethod · 0.45
makeSortedNamesMethod · 0.45
arrangeConsumerMethod · 0.45
MQMethod · 0.45
choiceManagerMethod · 0.45

Calls 11

getItemsMethod · 0.80
getIdMethod · 0.65
getValueMethod · 0.65
sizeMethod · 0.65
copyMethod · 0.65
clearMethod · 0.65
putMethod · 0.65
getKeyMethod · 0.65
putAllMethod · 0.65
toArrayMethod · 0.45
entrySetMethod · 0.45

Tested by 4

onProcessMethod · 0.36
testSortListMethod · 0.36
testSortedMapMethod · 0.36
testDiffMethod · 0.36