I have to make implement the data structure for a search engine. So there are different type of objects in my DS. I have a generic linked list and I want to only add those elements to the list which are not a part of the list now. Is there a method for comparing two object types in a more exhaustive way because .equals() is returning true every time?
public Boolean IsMember(T o) {
NodeX<T> temp = head;
while(temp!= null) {
if (temp.data.equals(o))
{//System.out.println("exec");
return true;}
temp = temp.next;
}
return false;
}
This is the isMember method of the LinkedList. This works only for string types. What can I change in this to make it work for all object types?
If I define an isEqual method for different objects that I am using, how can I use those methods here?