[xsde-users] find() in sequences

Duncan.Perrett at elekta.com Duncan.Perrett at elekta.com
Wed Oct 7 04:18:10 EDT 2009


Boris,

That's great.  I had assumed that the iterator support wasn't there.  I 
also realized that something wasn't right about my find_if() call not 
using Name().  I had been looking at ptr_fun, mem_fun, bind2nd etc in the 
STL book.  When you mentioned the predicate solution - I saw that it was 
in the book a few pages earlier.  Perfect.

However, I have since gone on to just do this ...

        for (NodeType::TxMessage_const_iterator j = 
i->TxMessage().begin(); j != i->TxMessage().end(); ++j) // for each 
TxMessage of the Node
        {
                if (j->Name() == "ADC1_data_dia")
                {
                        msgTxMsgNum = j;
                        msgNodeNum = i;
                        cout << "match for msg ADC1_data_carr" <<
                        " in Node " << i->Name() << " msg no. " << 
numCANMsgs++ << endl;
                }
 
                numCANMsgs++;
        }


Would installing the iterator support and using find_if() with a predicate 
be worth doing?  Would it be faster/smaller etc?
I may end up doing this sort of search once at initialisation so I'm not 
too worried about speed.


Thanks,

Duncan


More information about the xsde-users mailing list