同步西游的toolsutil
parent
09959ed6a3
commit
511fb8f41e
|
|
@ -86,6 +86,11 @@ public class ToolsUtil {
|
|||
return timeLong + TimeUtils.DAY * dayOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机数
|
||||
* @param array 数组
|
||||
* @return 随机数
|
||||
*/
|
||||
public static int getRandomInt(int[] array){
|
||||
int sum = Arrays.stream(array).sum();
|
||||
|
||||
|
|
@ -102,9 +107,6 @@ public class ToolsUtil {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// System.out.println("Random Value: " + randomValue);
|
||||
// System.out.println("Start Index: " + startIndex);
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
|
|
@ -148,6 +150,27 @@ public class ToolsUtil {
|
|||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* map转二维数组
|
||||
*/
|
||||
public static long[][] getTwoArrayLong(Map<Long, Long> map) {
|
||||
long[][] object = null;
|
||||
if (map != null && !map.isEmpty()) {
|
||||
int size = map.size();
|
||||
object = new long[size][2];
|
||||
|
||||
Iterator<Map.Entry<Long, Long>> iterator = map.entrySet().iterator();
|
||||
for (int i = 0; i < size; i++) {
|
||||
Map.Entry<Long, Long> entry = iterator.next();
|
||||
long key = entry.getKey();
|
||||
long value = entry.getValue();
|
||||
object[i][0] = key;
|
||||
object[i][1] = value;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public static int findKeyWithMaxValueLessThanB(Map<Integer, Integer> a, int b) {
|
||||
int maxKey = -1;
|
||||
int maxValue = Integer.MIN_VALUE;
|
||||
|
|
@ -205,6 +228,14 @@ public class ToolsUtil {
|
|||
return -1; // 如果没有找到匹配的元素,则返回 -1
|
||||
}
|
||||
|
||||
public static int getPackId(int id){
|
||||
return 100000 + id;
|
||||
}
|
||||
|
||||
public static int getOriginId(int id){
|
||||
return id % 100000;
|
||||
}
|
||||
|
||||
/**
|
||||
* type 需要小于10
|
||||
*/
|
||||
|
|
@ -212,10 +243,6 @@ public class ToolsUtil {
|
|||
return type * 100000 + id;
|
||||
}
|
||||
|
||||
public static int getOriginId(int id){
|
||||
return id % 100000;
|
||||
}
|
||||
|
||||
public static int[] getOriginIds(int id){
|
||||
int[] result = new int[2];
|
||||
result[0] = Integer.parseInt(String.valueOf(String.valueOf(id).charAt(0)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue