mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
Format code with prettier (#3375)
This commit is contained in:
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user