SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
I’m trying to merge xvalues of two data series (both must have equals xvalues).
First, i get a keys – collection of different keys, and want to insert this keys into second data series.
using (ds.SuspendUpdates())
{
int keyIndex = 0;
int dsIndex = ds.FindIndex(keys[0], SearchMode.RoundUp);
while (dsIndex < ds.XValues.Count)
{
if (keyIndex >= keys.Count) break;
if (ds.XValues[dsIndex] > keys[keyIndex])
{
ds.Insert(dsIndex, keys[keyIndex], Double.NaN);
keyIndex++;
}
dsIndex++;
}
}
But if ds.XValues.Count = 1200000 and keys’s count = 200000, that this method work to much time.
Complexity of this method is O(n), so i want to know what is performance (complexity) of data series insert method?
Hi Arthur,
Insert performance will be roughly the same as List.Insert, where we have one list for each column. E.g. Date, Open, High, Low, Close are 5 lists.
Insert requires that the underlying list is resized, all elements after the Insert are copied (moved) and the new elements copied (inserted).
DataSeries.InsertRange is a faster and better way to insert than point-by-point insert.
Hope this helps,
Andrew
Please login first to submit.