KLALB UDP TEST

This commit is contained in:
Administrator
2024-01-30 16:54:09 +08:00
parent 722ab9710f
commit b4fccf3a03
67 changed files with 1977 additions and 929 deletions
@@ -5,6 +5,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import java.util.List;
import java.util.UUID;
public class KLALBUtils {
@@ -54,4 +55,24 @@ public class KLALBUtils {
}
return fmt;
}
public static int binarySearchDATATPacketNumber(List<DATATPacket>lst,long number) {
int low =0;
int high=lst.size()-1;
int middle=0;
if(low>high||number<lst.get(low).getNumber()||number>lst.get(high).getNumber()) {
return -1;
}
while(low<=high) {
middle=(low+high)/2;
long xn=lst.get(middle).getNumber();
if(xn>number) {
high=middle-1;
}else if(xn<number) {
low=middle+1;
}else {
return middle;
}
}
return -1;
}
}