PointLineSeries.GetXMinMax() time complexity

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
jorge
Posts: 20
Joined: Tue Jun 28, 2016 7:54 am

PointLineSeries.GetXMinMax() time complexity

Post by jorge » Tue Jun 28, 2016 7:58 am

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.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: PointLineSeries.GetXMinMax() time complexity

Post by ArctionPasi » Tue Jun 28, 2016 8:21 am

The PointLineSeries 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;
        }
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;

            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

Post Reply