Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Array of string and fast search capabilities by specific string keyword

    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
    Super Contributor
    Join Date
    May 2004
    Posts
    2,267

    Re: Array of string and fast search capabilities by specific string keyword

    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
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: Array of string and fast search capabilities by specific string keyword

    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
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    235

    Re: Array of string and fast search capabilities by specific string keyword

    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
    Super Contributor
    Join Date
    May 2004
    Posts
    2,267

    Re: Array of string and fast search capabilities by specific string keyword

    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
    Join Date
    Jan 2005
    Location
    Helsinki, Finland
    Posts
    257

    Re: Array of string and fast search capabilities by specific string keyword

    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
  •  
×