java - How can I check if an object exists in a List by specialized comparing way? -


for example have list list<myclass>.

list.contains() use object.equals() comparing, have implement method myclass.equals() correct semantic, can't modify it.

is there api can use specialized comparing method/class checking except loop & check myself?

the list not sorted list can't use collections.binarysearch().

you can specify custom contains() method single instance of list, during instantiation such this:

list<string> list = new arraylist<string>() {          @override         public boolean contains(object o) {             // own implementation         }     }; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -