Compare objects in LinkedList.contains()

后端 未结 6 1732
梦谈多话
梦谈多话 2020-12-06 12:00

I want to be able to have LinkedList.contains() return true for a custom comparator.

Suppose that I have 1 LinkedList and 2 objects

LinkedList

        
6条回答
  •  情话喂你
    2020-12-06 12:30

    Rather than use a LinkedList to search through every element, Have you considered using a new HashSet(Comparator). This will efficiently compare the elements to find a match.

提交回复
热议问题