forked from KNEMC/KLALB
KLALB UDP TEST
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user