4减法- Function TimeMinus(arrTime1, arrTime2, Optional mode = 0)
- Dim kong As Boolean
-
- arr = arrTime1
- arr = FastSort(arr)
- arr1 = hb(arr)
- arr = arrTime2
- arr = FastSort(arr)
- arr2 = hb(arr)
- Dim brr()
- ReDim brr(LBound(arr1, 1) To UBound(arr1, 1) * UBound(arr2, 1), 1 To 2)
-
- ii1 = LBound(arr2, 1)
- For i = LBound(arr1, 1) To UBound(arr1, 1)
- kong = True
- For ii = ii1 To UBound(arr2, 1)
- If arr1(i, 1) >= arr2(ii, 1) And arr1(i, 2) <= arr2(ii, 2) Then kong = False: Exit For '全减
- If arr1(i, 1) >= arr2(ii, 2) Or arr1(i, 2) <= arr2(ii, 1) Then GoTo js '无交集
- bi = bi + 1
- kong = False
- ii1 = ii
- If arr1(i, 1) < arr2(ii, 2) Then brr(bi, 1) = arr1(i, 1) Else brr(bi, 1) = arr2(ii, 2)
- If arr1(i, 2) < arr2(ii, 1) Then brr(bi, 2) = arr1(i, 2) Else brr(bi, 2) = arr2(ii, 1)
-
- If arr1(i, 2) > arr2(ii, 2) Then kong = True: arr1(i, 1) = arr2(ii, 2) '继续
-
- js:
- Next
- If kong Then
- bi = bi + 1
- brr(bi, 1) = arr1(i, 1)
- brr(bi, 2) = arr1(i, 2)
- End If
- Next
-
-
- arr = FastSort(brr)
- TimeMinus = hb(arr)
-
- End Function
复制代码 |