×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    47

    RPointerArray problem with Find();

    Hello. I have following code:

    Code:
    RPointerArray<CMyType>* iContacts;
    CMyType* pFindContact = new (ELeave) CMyType(SomeValue);
    
    TInt arraySize = iContacts->Count(); // arraySize == 4 and it is valid value.
    
    TInt nIndex = iContacts->FindInOrder(pFindContact, TLinearOrder<CMyType>(CompareSomeValue)); // nIndex == -1
    
    arraySize = iContacts->Count(); // arraySize == 4 and it is valid value too.
    This is CompareSomeValue function:
    Code:
    TInt CContactsHandling::CompareSomeValue(const CMyType &aFirst, const CMyType &aSecond)
    {
        LOG("CContactsHandling::CompareSomeValue");
        TInt res = (aFirst.SomeValue == aSecond.SomeValue)
        LOG("CContactsHandling::CompareSomeValue res = %d", res);
        return res;
    }
    According the logs I can see that CompareSomeValue function calls just twice and in both cases res != 0. As result from time to time I cannot find value in array even if it is there. Where is my mistake?

  2. #2
    Nokia Developer Champion
    Join Date
    May 2004
    Posts
    2,266

    Re: RPointerArray problem with Find();

    The FindInOrder() assumes that existing object pointers in the array are ordered, is it true for your iContects?

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    47

    Re: RPointerArray problem with Find();

    No. Thank you.

Similar Threads

  1. Replies: 7
    Last Post: 2012-08-30, 17:40
  2. Problem with RPointerArray<HBufC> !!!!!!
    By PritamS60 in forum Symbian
    Replies: 3
    Last Post: 2010-05-11, 08:24
  3. RPointerArray
    By punty1984 in forum Symbian
    Replies: 10
    Last Post: 2008-07-22, 17:50
  4. problem destroying RPointerArray
    By doesitmatter in forum Symbian
    Replies: 9
    Last Post: 2008-02-24, 21:54
  5. RPointerArray
    By Deepa msc in forum General Development Questions
    Replies: 5
    Last Post: 2008-01-16, 09:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •