I have an ICollectionView
bound to a DataGrid which contains 1 million items and should be filtered as user types in a search text box. Due to the large number of items, filtering algorithm should be performance friendly.
This is my current string comparison (some part of filtering method):
static bool AreEqual(string str1, string str2)
{
var compareInfo = CultureInfo.InvariantCulture.CompareInfo;
bool result = compareInfo.IndexOf(str1, str2, CompareOptions.IgnoreNonSpace) > -1;
return result;
}
The CompareOptions.IgnoreNonSpace
ignore diacritics very well but ignores half space with Unicode \u200c too, which is not what I want. I just want to ignore diacritics.
bool compare1 = AreEqual("آبی","آبی"); //true, It's Okay.
bool compare2 = AreEqual("آبی", "ابی"); //true. It's Okay.
bool compare3 = AreEqual("آبی", "آبی"); //true. This is not what I want. It should return false
bool compare4 = AreEqual("آبی", "ابی"); //true. This is not what I want. It should return false.
Since, the performance is critical, I can't remove diacritics with normalizing strings before comparison.
One more question:
I want to filter CollectionView
, in a way that, first 10 results will be returned and continue to search in a background thread while user is reading current DataGrid
viewport. When user scrolls the DataGrid
, show next 10 results which are filtered in the background thread. I don't want user waits for CollectionView
to finish filtering 1 million items.