Reputation: 73
I am interested in the fastest search in sorted ArrayList
of String
.
What is a fast way?
I am using method contain
, but i think, there is a better way.
What about 2 threads? One from the front and second from behind.
List sorted contains elements of the same length.
aaa
bbb
ccc
ddd
eee
fff
ggg
.
.
What what is your opinion ?
Upvotes: 1
Views: 485
Reputation: 213233
This can be done with binary search. Java provides Collections.binarySearch()
.
Upvotes: 6