Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -44,7 +44,8 @@ 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;
@ -83,7 +84,8 @@ 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;
}
@ -114,7 +116,13 @@ 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;
@ -136,7 +144,9 @@ 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()
);
}
/**