style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -44,8 +44,7 @@ public class DynamicArray<E> implements Iterable<E> {
*/
public void add(final E element) {
if (this.size == this.elements.length) {
this.elements =
Arrays.copyOf(this.elements, newCapacity(2 * this.capacity));
this.elements = Arrays.copyOf(this.elements, newCapacity(2 * this.capacity));
}
this.elements[this.size] = element;
@ -84,8 +83,7 @@ public class DynamicArray<E> implements Iterable<E> {
fastRemove(this.elements, index);
if (this.capacity > DEFAULT_CAPACITY && size * 4 <= this.capacity) {
this.elements =
Arrays.copyOf(this.elements, newCapacity(this.capacity / 2));
this.elements = Arrays.copyOf(this.elements, newCapacity(this.capacity / 2));
}
return oldElement;
}
@ -116,13 +114,7 @@ public class DynamicArray<E> implements Iterable<E> {
final int newSize = this.size - 1;
if (newSize > index) {
System.arraycopy(
elements,
index + 1,
elements,
index,
newSize - index
);
System.arraycopy(elements, index + 1, elements, index, newSize - index);
}
elements[this.size = newSize] = null;
@ -144,9 +136,7 @@ public class DynamicArray<E> implements Iterable<E> {
*/
@Override
public String toString() {
return Arrays.toString(
Arrays.stream(this.elements).filter(Objects::nonNull).toArray()
);
return Arrays.toString(Arrays.stream(this.elements).filter(Objects::nonNull).toArray());
}
/**