Anyone knows what is the time complexity of this method? Is it done in constant time or linear to the number of points in the series?
Thanks.
PointLineSeries.GetXMinMax() time complexity
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: PointLineSeries.GetXMinMax() time complexity
The PointLineSeries implementation is like this:
So it's just peeking the first and last data point in the series.
FreeformPointLineSeries the implementation is like this:
Code: Select all
public override bool GetXMinMax(out double xMin, out double xMax)
{
xMin = 0;
xMax = 0;
if (m_iActualPointCount <= 0)
{
return false;
}
if (m_pointsType == PointsType.Points)
{
xMin = m_points[0].X;
xMax = m_points[m_iActualPointCount - 1].X;
}
else
{
xMin = m_pointsWithErrors[0].X;
xMax = m_pointsWithErrors[m_iActualPointCount - 1].X;
}
return true;
}
FreeformPointLineSeries the implementation is like this:
Code: Select all
public override bool GetXMinMax(out double xMin, out double xMax)
{
xMin = 0;
xMax = 0;
if (m_iActualPointCount <= 0)
return false;
double dMin = double.MaxValue;
double dMax = double.MinValue;
double dX;
if (m_pointsType == PointsType.Points)
{
for (int i = 0; i < m_iActualPointCount; i++)
{
dX = m_aPoints[i].X;
if (dX > dMax)
dMax = dX;
if (dX < dMin)
dMin = dX;
}
}
else
{
for (int i = 0; i < m_iActualPointCount; i++)
{
dX = m_aPointsWithErrors[i].X;
if (dX > dMax)
dMax = dX;
if (dX < dMin)
dMin = dX;
}
}
xMin = dMin;
xMax = dMax;
return true;
}
LightningChart Support Team, PT