From d719f328bcb2900f5b5318d999166f8702b4d7fe Mon Sep 17 00:00:00 2001 From: godotg Date: Sun, 25 Sep 2022 12:34:33 +0800 Subject: [PATCH] styl[array]: rearrange code --- .../protocol/collection/ArrayIntList.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/protocol/src/main/java/com/zfoo/protocol/collection/ArrayIntList.java b/protocol/src/main/java/com/zfoo/protocol/collection/ArrayIntList.java index 118b5ca3..b27d7a6b 100644 --- a/protocol/src/main/java/com/zfoo/protocol/collection/ArrayIntList.java +++ b/protocol/src/main/java/com/zfoo/protocol/collection/ArrayIntList.java @@ -152,7 +152,7 @@ public class ArrayIntList implements List { var appendArray = ArrayUtils.intToArray(new ArrayList<>(collection)); var appendLength = appendArray.length; - int moved = size - index; + var moved = size - index; if (moved > 0) { System.arraycopy(array, index, array, index + appendLength, moved); } @@ -275,6 +275,20 @@ public class ArrayIntList implements List { return ArrayUtils.toList(array).subList(fromIndex, toIndex); } + @Override + public String toString() { + var builder = new StringBuilder(); + builder.append('['); + for (var i = 0; i < size; i++) { + builder.append(array[i]); + if (i < size - 1) { + builder.append(", "); + } + } + builder.append(']'); + return builder.toString(); + } + private class FastIterator implements Iterator { int cursor; // index of next element to return int lastCursor = -1; // index of last element returned; -1 if no such @@ -345,18 +359,4 @@ public class ArrayIntList implements List { lastCursor = -1; } } - - @Override - public String toString() { - var builder = new StringBuilder(); - builder.append('['); - for (var i = 0; i < size; i++) { - builder.append(array[i]); - if (i < size - 1) { - builder.append(", "); - } - } - builder.append(']'); - return builder.toString(); - } }