Check if one list contains element from the other

前端 未结 12 2639
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 20:45

I have two lists with different objects in them.

List list1;
List list2;

I want to check if element from list

12条回答
  •  天涯浪人
    2020-11-30 21:27

    Can you define the type of data you hold ? is it big data ? is it sorted ? I think that you need to consider different efficiency approaches depending on the data.

    For example, if your data is big and unsorted you could try and iterate the two lists together by index and store each list attribute in another list helper. then you could cross check by the current attributes in the helper lists.

    good luck

    edited : and I wouldn't recommend overloading equals. its dangerous and probably against your object oop meaning.

提交回复
热议问题