Skip to content

Commit

Permalink
util: get rid of ArrayUtil#reverse(char[]) as it is unused (no extern…
Browse files Browse the repository at this point in the history
…al usages as well) (IDEA-CR-6402)
  • Loading branch information
segrey committed Nov 2, 2015
1 parent e500c55 commit 7e21990
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
6 changes: 0 additions & 6 deletions platform/util/src/com/intellij/util/ArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,6 @@ public static int[] reverseArray(@NotNull int[] array) {
return newArray;
}

public static void reverse(@NotNull char[] array) {
for (int i = 0; i < array.length / 2; i++) {
swap(array, array.length - i - 1, i);
}
}

@Contract(pure=true)
public static int lexicographicCompare(@NotNull String[] obj1, @NotNull String[] obj2) {
for (int i = 0; i < Math.max(obj1.length, obj2.length); i++) {
Expand Down
24 changes: 9 additions & 15 deletions platform/util/testSrc/com/intellij/util/ArrayUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,19 @@ private static <T> void assertEqualsArray(T[] actual, T... expected) {
}
}

private static void assertArrayEquals(char[] expected, char[] actual) {
private static void assertArrayEquals(int[] expected, int[] actual) {
assertTrue(Arrays.equals(expected, actual));
}

public void testReverse() throws Exception {
char[] a = new char[]{};
ArrayUtil.reverse(a);
assertArrayEquals(new char[]{}, a);

a = new char[]{'1'};
ArrayUtil.reverse(a);
assertArrayEquals(new char[]{'1'}, a);

a = new char[]{'1', '2', '3', '4'};
ArrayUtil.reverse(a);
assertArrayEquals(new char[]{'4', '3', '2', '1'}, a);
checkArrayReverse(new int[]{}, new int[]{});
checkArrayReverse(new int[]{1}, new int[]{1});
checkArrayReverse(new int[]{1, 2, 3, 4}, new int[]{4, 3, 2, 1});
checkArrayReverse(new int[]{1, 2, 3, 4, 5}, new int[]{5, 4, 3, 2, 1});
}

a = new char[]{'1', '2', '3', '4', '5'};
ArrayUtil.reverse(a);
assertArrayEquals(new char[]{'5', '4', '3', '2', '1'}, a);
private static void checkArrayReverse(int[] array, int[] expectedReversedArray) {
int[] reversed = ArrayUtil.reverseArray(array);
assertArrayEquals(expectedReversedArray, reversed);
}
}

0 comments on commit 7e21990

Please sign in to comment.