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:
| Value | Description |
|---|---|
| StartsWith | Matches all strings that start with a given substring. This is the default value. |
| WordStartsWith | Matches all strings that contain a word starting with a given substring. |
| MultiWordStartsWithCount | Matches all strings that contain a word starting with one of the words of a given substring and orders the matched strings by the number of matched words. |
| Contains | Matches all strings that contain a given substring. |
| EndsWith | Matches all strings that end with a given substring. |
| WordEndsWith | Matches all strings that contains a word ending with a given substring. |
| Wildcard | Matches all strings that match a given wildcard pattern. The popular MS DOS symbology is used for the pattern, i.e. you can use the special character '*' to denote zero or more characters and '?' to denote exactly one character. For example, the pattern "B?l*" in a list of countries matches "Belarus", "Belgium", "Belize", "Bolivia" and "Bulgaria". |
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".