コード例 #1
0
ファイル: GraphLineData.cs プロジェクト: lulzzz/Nucleus
 /// <summary>
 /// Initialise a new GraphLineData
 /// </summary>
 /// <param name="name"></param>
 /// <param name="data"></param>
 public GraphLineData(string name, LinearIntervalDataSet data)
 {
     Name = name;
     Data = data;
 }
コード例 #2
0
        /// <summary>
        /// Envelope this plot with another
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public LinearIntervalDataSet Envelope(LinearIntervalDataSet other)
        {
            var    result = new LinearIntervalDataSet();
            int    iA     = 0;
            int    iB     = 0;
            double tA     = Keys[0];
            double tB     = other.Keys[0];

            while (iA < Count || iB < Count)
            {
                // Find the next lowest key in either list and envelope the values
                // at that position
                if (tA < tB)
                {
                    result.Add(tA, Values[iA].Union(other.ValueAt(tA)));
                    iA++;
                    if (iA < Count)
                    {
                        tA = Keys[iA];
                    }
                    else
                    {
                        tA = double.MaxValue;
                    }
                }
                else if (tB < tA)
                {
                    result.Add(tB, ValueAt(tB).Union(other.Values[iB]));
                    iB++;
                    if (iB < Count)
                    {
                        tB = other.Keys[iB];
                    }
                    else
                    {
                        tB = double.MaxValue;
                    }
                }
                else //tA == tB
                {
                    result.Add(tA, Values[iA].Union(other.Values[iB]));
                    iA++;
                    iB++;
                    if (iA < Count)
                    {
                        tA = Keys[iA];
                    }
                    else
                    {
                        tA = double.MaxValue;
                    }
                    if (iB < Count)
                    {
                        tB = Keys[iB];
                    }
                    else
                    {
                        tB = double.MaxValue;
                    }
                }
                //Hmmm... may fail if either contains a key at infinity...?
            }
            return(result);
        }