Exemplo n.º 1
0
 private bool isFile(HistoryFileDataBean hisBean)
 {
     if (hisBean.StartTime > EndTime)
     {
         return(false);
     }
     if (hisBean.EndTime < StartTime)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        private void getIndex(HistoryFileDataBean hisBn, List <byte[]> sourBts, ref int index, ref int endIndex)
        {
            int start = 0;
            int end   = sourBts.Count;
            int mid   = end / 2;

            if (sourBts.Count == 0)
            {
                index = -1;
                return;
            }
            if (hisBn.StartTime < StartTime)
            {
                if (mid + 1 >= sourBts.Count)
                {
                    if (getBtTime(sourBts[mid]) < StartTime)
                    {
                        index = -1;
                    }
                    else if (getBtTime(sourBts[mid]) >= StartTime)
                    {
                        index = sourBts.Count - 1;
                    }
                    return;
                }

                while (start <= mid)
                {
                    if (getBtTime(sourBts[mid]) >= StartTime)
                    {
                        end = mid;
                    }
                    else
                    {
                        if (getBtTime(sourBts[mid + 1]) >= StartTime)
                        {
                            index = mid;
                            break;
                        }
                        start = mid;
                    }
                    mid = (start + end) / 2;
                }
            }
            if (hisBn.EndTime > EndTime)
            {
                while (start <= mid)
                {
                    if (getBtTime(sourBts[mid]) >= EndTime)
                    {
                        end = mid;
                    }
                    else
                    {
                        start = mid;
                        if (getBtTime(sourBts[mid + 1]) >= EndTime)
                        {
                            endIndex = mid;
                            break;
                        }
                    }
                    mid = (start + end) / 2;
                }
            }
        }