commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Dacek <m...@syberion.com>
Subject Re: [Text, Lang] Matching two CharSequence instances
Date Sat, 02 Mar 2019 16:59:09 GMT
Is your proposed method a stepwise charAt comparison across both, assuming
non-null and equal length?
Doesn't seem like a bad idea, though I'm curious whether there's a use-case
where toString() on both and comparing isn't more expedient.

On Sat, Mar 2, 2019 at 11:53 AM Alex Herbert <alex.d.herbert@gmail.com>
wrote:

> I am helping with the PR for TEXT-126 to add to the similarity package.
>
> Part of the new algorithm requires identifying if two CharSequences are
> identical. Is there a utility in Text to do something like this:
>
> public static boolean CharSequenceUtils.equals(CharSequence, CharSequence);
>
> I cannot find one with a quick regex search of the library. I am not
> familiar with Lang either but this is a dependency so a method from there
> could be used.
>
> The current PR is using left.equals(right) on the input CharSequence to
> compare to one to another which is wrong if the two input CharSequences do
> not support matching, e.g. if the input was a String and StringBuilder then
> String.equals(StringBuilder) would not match, even if the characters were
> the same.
>
> Regards,
>
> Alex
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message