From 0e372a6ad17d726daba182e06385f0f36fbb3316 Mon Sep 17 00:00:00 2001 From: IBue <> Date: Fri, 6 Dec 2024 19:51:56 +0100 Subject: [PATCH] [StringUtils::indexOfAnyBut] further reduction of algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit by simplifying set consideration: find index i of first char in seq such that (seq.codePointAt(i) ∉ { x ∈ codepoints(searchChars) }) --- .../java/org/apache/commons/lang3/StringUtils.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 999284fc1c2..0af23fff70c 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -28,7 +28,6 @@ import java.util.Locale; import java.util.Objects; import java.util.Set; -import java.util.function.Predicate; import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -2819,7 +2818,7 @@ public static int indexOfAny(final CharSequence cs, final String searchChars) { /** * Searches a CharSequence to find the first index of any * character not in the given set of characters, i.e., - * find index i of first char in cs such that (cs.codePointAt(i) ∈ {x ∈ codepoints(cs) ∣ x ∉ codepoints(searchChars) }) + * find index i of first char in cs such that (cs.codePointAt(i) ∉ { x ∈ codepoints(searchChars) }) * *
A {@code null} CharSequence will return {@code -1}. * A {@code null} or zero length search array will return {@code -1}.
@@ -2851,7 +2850,7 @@ public static int indexOfAnyBut(final CharSequence cs, final char... searchChars /** * Search a CharSequence to find the first index of any * character not in the given set of characters, i.e., - * find index i of first char in seq such that (seq.codePointAt(i) ∈ {x ∈ codepoints(seq) ∣ x ∉ codepoints(searchChars) }) + * find index i of first char in seq such that (seq.codePointAt(i) ∉ { x ∈ codepoints(searchChars) }) * *A {@code null} CharSequence will return {@code -1}. * A {@code null} or empty search string will return {@code -1}.
@@ -2876,16 +2875,13 @@ public static int indexOfAnyBut(final CharSequence seq, final CharSequence searc if (isEmpty(seq) || isEmpty(searchChars)) { return INDEX_NOT_FOUND; } - final Set