/// <summary> /// 指定された時間と同じか後に作られた PacketBoard のうち、一番古いものへの index を返します /// </summary> /// <param name="targetTime">検索に用いる時間</param> /// <returns>index</returns> public int BinarySearchNext(double targetTime) { if (list.Count <= 0) { return(0); } int head = 0; int tail = list.Count - 1; while (head <= tail) { int where = (head + tail) / 2; PacketBoard pb = list[where]; if (pb.CreatedTimeMillisecond <= targetTime) { if (where + 1 >= list.Count) { return(0); } else if (list[where + 1].CreatedTimeMillisecond > targetTime) { return(where + 1); } head = where + 1; } else { tail = where - 1; } } return(0); }
public static int Compare(Object x, Object y) { try { PacketBoard a = (PacketBoardBallistic)x; PacketBoard b = (PacketBoardBallistic)y; if (a.PositionZ == b.PositionZ) { return(0); } if (a.PositionZ > b.PositionZ) { return(1); } return(-1); } catch { return(0); } }
/// <summary> /// 要素をひとつ追加します /// </summary> /// <param name="obj">追加される要素</param> public void Add(PacketBoard pb) { if (pb == null) { return; } double targetTime = pb.CreatedTimeMillisecond; if (list.Count >= maxSize) { list.Remove(list[0]); } if (list.Count == 0) { list.Add(pb); } else { int index = BinarySearchPrev(targetTime); list.Insert(index + 1, pb); } }
public int CompareTo(PacketBoard x) { return(PacketBoardBallistic.Compare(this, x)); }
public int CompareTo(PacketBoard x) { return(PacketBoardLay.Compare(this, x)); }