The implementation of Find() method of CList class is that it compares the elements using == operator. In your case the element is a pointer to a struct. The Find() will be merely trying to match the address of the element with the parameter you are passing to it.
What it means that with the current design you will not be able to locate the element without storing the addresses of each element in the gDoubleListDataNode somewhere in a separate collection, even if you define the equality operator==
for your struct.
You have two options.
You can define your list as
typedef CList<DoubleListDataNode, DoubleListDataNode&> listDoubleListDataNode;
. When you do this you will have to populate it with the elements, not the pointers. For yourstruct DoubleListDataNode
, however, you will have to defineoperator=
andoperator==
. When you define the latter you can implement it that it will be using nSequenceIDInstead of using CList, you can use CMap. Define it as
typedef CMap<int, int&, DoubleListDataNode *, DoubleListDataNode *> mapDoubleListDataNode;
This way you will be able to use the power of MFC's hash tables to quickly locate required element in the map. One note though: The values in the map will be unique