コード例 #1
0
ファイル: Summary.cs プロジェクト: abs508/jHc
        /// <summary>
        /// Sets the fastest boy time
        /// </summary>
        /// <param name="key">athlete's key</param>
        /// <param name="name">athlete's name</param>
        /// <param name="time">athlete's time</param>
        /// <param name="date">date of the time</param>
        public void SetFastestBoy(
            int key,
            string name,
            TimeType time,
            DateType date)
        {
            if (FastestBoys.Count > 0 && time < FastestBoys[FastestBoys.Count - 1].Time)
            {
                for (int index = 0; index < FastestBoys.Count; ++index)
                {
                    if (time < FastestBoys[index].Time)
                    {
                        FastestBoys.Insert(index, new AthleteTime(key, name, time, date));
                        break;
                    }
                }
            }
            else if (FastestBoys.Count < maxSize)
            {
                FastestBoys.Add(new AthleteTime(key, name, time, date));
            }

            // Remove the last element if the list now exceeds the maximum size.
            if (FastestBoys.Count > maxSize)
            {
                FastestBoys.RemoveAt(FastestBoys.Count - 1);
            }

            this.FastestDataChangedEvent?.Invoke(this, new EventArgs());
        }
コード例 #2
0
ファイル: Summary.cs プロジェクト: abs508/jHc
 /// <summary>
 /// Remove a record corresponding to the argument data if one exists.
 /// </summary>
 /// <param name="key">athlete key</param>
 /// <param name="name">athlete name</param>
 /// <param name="time">athlete time</param>
 public void RemoveFastestBoy(
     int key,
     string name,
     TimeType time)
 {
     if (FastestBoys.Count > 0)
     {
         for (int index = 0; index < FastestBoys.Count; ++index)
         {
             if (key == FastestBoys[index].Key &&
                 name == FastestBoys[index].Name &&
                 time == FastestBoys[index].Time)
             {
                 FastestBoys.RemoveAt(index);
                 this.FastestDataChangedEvent?.Invoke(this, new EventArgs());
                 return;
             }
         }
     }
 }