This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 8b31797ce94e565116cef5a46a65cf02fe5bb83f Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Jun 14 15:28:55 2025 -0400 Sort members --- .../java/org/apache/commons/lang3/ArrayUtils.java | 80 +++++++++++----------- .../commons/lang3/time/FastDateParserTest.java | 20 +++--- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index c2541cc25..30944a549 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -5300,46 +5300,6 @@ public static long[] removeAll(final long[] array, final int... indices) { return (long[]) removeAll((Object) array, indices); } - /** - * Removes multiple array elements specified by indices. - * - * @param array the input array, will not be modified, and may be {@code null}. - * @param indices to remove. - * @return new array of same type minus elements specified by the set bits in {@code indices}. - */ - // package protected for access by unit tests - static Object removeAt(final Object array, final BitSet indices) { - if (array == null) { - return null; - } - final int srcLength = getLength(array); - // No need to check maxIndex here, because method only currently called from removeElements() - // which guarantee to generate only valid bit entries. -// final int maxIndex = indices.length(); -// if (maxIndex > srcLength) { -// throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength); -// } - final int removals = indices.cardinality(); // true bits are items to remove - final Object result = Array.newInstance(array.getClass().getComponentType(), srcLength - removals); - int srcIndex = 0; - int destIndex = 0; - int count; - int set; - while ((set = indices.nextSetBit(srcIndex)) != -1) { - count = set - srcIndex; - if (count > 0) { - System.arraycopy(array, srcIndex, result, destIndex, count); - destIndex += count; - } - srcIndex = indices.nextClearBit(set); - } - count = srcLength - srcIndex; - if (count > 0) { - System.arraycopy(array, srcIndex, result, destIndex, count); - } - return result; - } - /** * Removes multiple array elements specified by index. * @@ -5785,6 +5745,46 @@ public static <T> T[] removeAllOccurrences(final T[] array, final T element) { return (T[]) removeAt(array, indexesOf(array, element)); } + /** + * Removes multiple array elements specified by indices. + * + * @param array the input array, will not be modified, and may be {@code null}. + * @param indices to remove. + * @return new array of same type minus elements specified by the set bits in {@code indices}. + */ + // package protected for access by unit tests + static Object removeAt(final Object array, final BitSet indices) { + if (array == null) { + return null; + } + final int srcLength = getLength(array); + // No need to check maxIndex here, because method only currently called from removeElements() + // which guarantee to generate only valid bit entries. +// final int maxIndex = indices.length(); +// if (maxIndex > srcLength) { +// throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength); +// } + final int removals = indices.cardinality(); // true bits are items to remove + final Object result = Array.newInstance(array.getClass().getComponentType(), srcLength - removals); + int srcIndex = 0; + int destIndex = 0; + int count; + int set; + while ((set = indices.nextSetBit(srcIndex)) != -1) { + count = set - srcIndex; + if (count > 0) { + System.arraycopy(array, srcIndex, result, destIndex, count); + destIndex += count; + } + srcIndex = indices.nextClearBit(set); + } + count = srcLength - srcIndex; + if (count > 0) { + System.arraycopy(array, srcIndex, result, destIndex, count); + } + return result; + } + /** * Removes the first occurrence of the specified element from the * specified array. All subsequent elements are shifted to the left diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index c0d89039e..29b91a6db 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -152,6 +152,16 @@ private static Calendar initializeCalendar(final TimeZone timeZone) { return cal; } + static ArgumentSets testParsesFactory() { + // @formatter:off + return ArgumentSets + .argumentsForFirstParameter(LONG_FORMAT, SHORT_FORMAT) + .argumentsForNextParameter(LocaleUtils.availableLocaleList()) + .argumentsForNextParameter(NEW_YORK, REYKJAVIK, TimeZones.GMT) + .argumentsForNextParameter(2003, 1940, 1868, 1867, 1, -1, -1940); + // @formatter:on + } + private final TriFunction<String, TimeZone, Locale, DateParser> dateParserProvider = (format, timeZone, locale) -> new FastDateParser(format, timeZone, locale, null); @@ -530,16 +540,6 @@ void testParseOffset() { assertEquals(cal.getTime(), date); } - static ArgumentSets testParsesFactory() { - // @formatter:off - return ArgumentSets - .argumentsForFirstParameter(LONG_FORMAT, SHORT_FORMAT) - .argumentsForNextParameter(LocaleUtils.availableLocaleList()) - .argumentsForNextParameter(NEW_YORK, REYKJAVIK, TimeZones.GMT) - .argumentsForNextParameter(2003, 1940, 1868, 1867, 1, -1, -1940); - // @formatter:on - } - @CartesianTest @CartesianTest.MethodFactory("testParsesFactory") // Check that all Locales can parse the formats we use