Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Voxera113975yI think that would depend on what related means and what comparison is in this case.
If you need exact matches an algorithm that can short circuit at first error is probably good, but if you need a more fuzzy match its another case altogether. -
I hope you meant "implemented" and not "implanted"?
If so then why not just benchmark them all against your use case? Opinions are one this but this sort of thing is done best with hard data. -
@12bitfloat compare nullesness first, then - length, and then - what you've said. Considering that length is a property of string and not smth you have to calculate each time
-
@12bitfloat although comparing byte-by-byte and failing at a first mismatch is likely to be faster than digesting the whole stringS in a first place..
-
@12bitfloat since java strings are immutable.. Doesn't java.lang.String calc hash at construction time and cache it locally? I've got to admit I've never checked
-
@netikras It calculates it the first time it's needed IIRC, so in the first call to hashcode()
-
you wont get below O(n*m) with two checks unless you start using heuristics. Look into boyer moore
Related Rants
What is the best string comparison algorithm ?
Example Use case: group messages from your telco into groups of related messages.
I have gone through the various algos and implanted them. I just want your opinion if you have experience on this.
rant
algorithm
string