Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User madsum's Avatar
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257
    Hello,

    There are various kinds of arrays in symbain. I would like to know is there any array where I can store non-modifiable string and later on I can search the array by the string. For instance, my array contains 3 strings such as follows:

    1. “abc”
    2. “efg”
    3. “hij”

    Later I want to search “efg” exist in my array or not by keyword "efg". So could anyone suggest which array provides that kind of functionality (preferable fast searching)? I can build my own logic by creating array and access each element and check contains of the element and so on. But I think there might be some API already exists that provides such capabilities.

  2. #2
    Nokia Developer Champion chenziteng's Avatar
    Join Date
    May 2004
    Posts
    2,265
    I think you should use "Descriptor Arrays" like CDesCArrayFlat and CDesCArraySeg. They are sub-classes of CDesCArray, so you can use CDesCArray::InsertIsqL() to inserts descriptors into the array at positions which maintain the sequence of the descriptors, and then use FindIsq() to find the position of a descriptor element within the array which matches the specified descriptor — using a binary search technique.

  3. #3
    Registered User madsum's Avatar
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257
    Thanks for the reply! I'm a bit confused about the enamuration TKeyCmpText which is a parameter of TInt FindIsq(const TDesC16& aPtr,TInt& aPos,TKeyCmpText aTextComparisonType=ECmpFolded) const; and TInt InsertIsqL(const TDesC16& aPtr,TKeyCmpText aTextComparisonType=ECmpFolded);

    I read the API ref for TKeyCmpText. Could not understand it clearly. Also for FindIsq() method, API doc says "Finds the position of a descriptor element within the array which matches the specified descriptor — using a binary search technique. The array must be in sequence, otherwise the outcome is unpredictable."

    So what does it mean by "The array must be in sequence"???

  4. #4
    Regular Contributor ViruDoshi's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    235
    By in sequence is means in alphanumeric order,

    So you file should be:

    A, B, C, D not A, C, D, B.

    ViruDoshi
    ~ No Style Without Substance ~

  5. #5
    Nokia Developer Champion chenziteng's Avatar
    Join Date
    May 2004
    Posts
    2,265
    Binary search is an algorithm for finding a value in a array. It requires the elements in the array be sorted (i.e. in sequence).

    As to aTextComparisonType, I think ECmpNormal is better than ECmpFolded, because the latter will ignore character differences like case and accents.

  6. #6
    Registered User madsum's Avatar
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257
    Thanks guys! This is not always easy to understand symbian API reference just by reading the doc. It is always worth testing the API in the project and then manage to get the idea what they wanted to meant in doc. This is not just for my poor understanding of English language; this is same for a native English speaker.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved