Balzanka / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Add contains, indexOf & lastIndexOf to ObjectArrays #1354

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Yes, one can use

ImmutableList.copyOf(array).contains(val)

or

Arrays.asList(array).contains(val)

or (if the array is sorted)

Arrays.binarySearch(array, val)

but in some cases it might be better not to create a new Object with an array 
clone.

Similar methods exist on the primitives classes.

Original issue reported on code.google.com by sebastia...@gmail.com on 26 Mar 2013 at 11:33

GoogleCodeExporter commented 9 years ago
Arrays.asList(array) is the way to do this. Note that Arrays.asList is a _view_ 
of the array; it does not clone the array, so the work involved is negligible.

Original comment by cgdec...@gmail.com on 27 Mar 2013 at 3:52

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08