有序插入:
public void insetData(long value){
int i=0;
for(i;i<element;i++){
if(value<attr[i]){break;}
}
for(int j=element;j>i;j--){
attr[j]=attr[j-1];
}
attr[i]=value;
element++;
}
二分法查找:
public void binarySearch(long value){
int middle=0;
int low=0;
int pow=element;
while(true){
middle=(pow+low)/2;
if(arr[middle]==value){
return middle;
}else if(low>pow){
return -1;
}else{
if(arr[middle]>value){
pow=middle-1;
}else{
low=middle+1;
}
}
}
}