Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Dec 30, 2024
1 parent 95ca91d commit 6143bef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package kala.collection.base;

import kala.Conditions;
import kala.annotations.UnstableName;
import kala.control.Option;
import kala.annotations.Covariant;
Expand Down
13 changes: 6 additions & 7 deletions kala-base/src/main/java/kala/collection/base/ObjectArrays.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package kala.collection.base;

import kala.Conditions;
import kala.annotations.StaticClass;
import kala.collection.factory.CollectionFactory;
import kala.control.Option;
Expand Down Expand Up @@ -507,9 +506,10 @@ public static int lastIndexWhere(Object @NotNull [] array, @NotNull Predicate<?>

//region Misc Operations

public static Object @NotNull [] slice(Object @NotNull [] array, int beginIndex, int endIndex) {
public static Object @NotNull [] slice(Object @NotNull [] array, @Index int beginIndex, @Index int endIndex) {
final int length = array.length;
Conditions.checkPositionIndices(beginIndex, endIndex, length);
beginIndex = Indexes.checkBeginIndex(beginIndex, length);
endIndex = Indexes.checkEndIndex(beginIndex, endIndex, length);

final int newLength = endIndex - beginIndex;
if (newLength == 0) {
Expand Down Expand Up @@ -601,11 +601,10 @@ public static int lastIndexWhere(Object @NotNull [] array, @NotNull Predicate<?>
return Arrays.copyOf(array, count);
}

public static Object @NotNull [] updated(Object @NotNull [] array, int index, Object newValue) {
final int size = array.length;

Objects.checkIndex(index, size);
public static Object @NotNull [] updated(Object @NotNull [] array, @Index int index, Object newValue) {
final int length = array.length;

index = Indexes.checkElementIndex(index, length);
Object[] newValues = array.clone();
newValues[index] = newValue;
return newValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kala.Conditions;
import kala.annotations.StaticClass;
import kala.control.primitive.${Type}Option;
import kala.function.*;
import kala.index.*;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import static org.junit.jupiter.api.Assertions.*;

public class GenericArraysTest {
public class ArraysTest {

private static void assertIteratorEquals(Iterable<?> expected, Iterator<?> actual) {
assertIterableEquals(expected, Iterators.collect(actual, new ArrayList<>()));
Expand Down

0 comments on commit 6143bef

Please sign in to comment.