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
Post a Comment