Framework / Data Structures / String Maps and String Sets
In This Topic

    String Maps and String Sets

    In This Topic

    Nevron Open Vision provides two special classes for working with string sets - the NStringMap and the NStringSet. Although similar to standard maps and sets on the outside, they are implemented differently and provide an optimized way for various string search methods such as:

    The results of these methods depend on whether the string comparisons are case sensitive or not, which is specified by passing true or false to the constructor. The following code example demonstrates how to create and initialize a string set and perform a wildcard serch on it:

    String Set Example
    Copy Code
    string[] Words = new string[] { "bar", "bat", "car", "cat", "far", "fat", "ward", "warda", "wa", "w", "wra", "warhead" };
    
    NStringSet stringSet = new NStringSet(true);
    for (int i = 0; i < Words.Length; i++)
    {
        stringSet.Add(Words[i]);
    }
    
    INSet<string> matches = m_Words.FindStrings("*ar", ENStringMatchMode.Wildcard);
    

    The set returned by wildcard pattern search in this case will contain the strings "bar", "car" and "far".

    Note that the optimizations of the NStringSet and NStringMap classes for the string search methods above come at the cost of slower access by key. For the NStringSet and NStringMap classes it is not O(1) as in a hash table based map, but O(log N). That is why you should use the generic NUniqueSet or NMap class with a string type parameter when you don't need the special string search methods that the NStringSet and NStringMap offer.
    See Also