| | |
| | | return string.Empty;
|
| | | }
|
| | |
|
| | | //一维数组:来源格式如 1|2|3|4
|
| | | public static T[] GetMultipleStr<T>(string msg) where T : struct
|
| | | {
|
| | | string[] segs = GetMultipleStr(msg);
|
| | |
| | | }
|
| | |
|
| | | //{'17':['63','6','27'],'65':['800'],'55':['139'],'19':['1000','2600','130']}
|
| | | public static Regex userDataRegex = new Regex(@"'([0-9]+)':\[(.*?)\]", RegexOptions.Singleline);
|
| | | public static Dictionary<int, List<int>> Analysis(string val)//正则表达式的字符串分割
|
| | | {
|
| | | string s = ServerStringTrim(val);
|
| | |
| | | //}
|
| | | }
|
| | |
|
| | | public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | | {
|
| | | return new Dictionary<int, List<int>>();
|
| | | }
|
| | | var dict = JsonMapper.ToObject<Dictionary<string, List<int>>>(jsonStr);
|
| | | Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();
|
| | |
|
| | | foreach (var item in dict)
|
| | | {
|
| | | result[int.Parse(item.Key)] = item.Value;
|
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | //json格式: {"1":1}
|
| | | public static Dictionary<int, int> ParseIntDict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | //json格式: {"1":[1,2],"2":[3,4]}
|
| | | public static Dictionary<int, int[]> ParseIntArrayDict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | //json格式: {"1":[[1,2],[3,4]]}
|
| | | public static Dictionary<int, int[][]> ParseIntArray2Dict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | //json格式: {"1":{"1":1,"2":2},"2":{"3":3,"4":4}}
|
| | | public static Dictionary<int, Dictionary<int, int>> ParseDictInDict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | | {
|
| | | return new Dictionary<int, Dictionary<int, int>>();
|
| | | }
|
| | | var dict = JsonMapper.ToObject<Dictionary<string, Dictionary<string, int>>>(jsonStr);
|
| | | Dictionary<int, Dictionary<int, int>> result = new Dictionary<int, Dictionary<int, int>>();
|
| | |
|
| | | foreach (var item in dict)
|
| | | {
|
| | | Dictionary<int, int> subDict = new Dictionary<int, int>();
|
| | | foreach (var subItem in item.Value)
|
| | | {
|
| | | subDict[int.Parse(subItem.Key)] = subItem.Value;
|
| | | }
|
| | | result[int.Parse(item.Key)] = subDict;
|
| | | }
|
| | | |
| | | return result;
|
| | | }
|
| | |
|
| | | //万分率转为每个id对应的概率 [[万分概率,id1],[万分概率,id2]]
|
| | | public static Dictionary<int, int> GetRateDict(int[][] rateArray)
|
| | | {
|
| | | Dictionary<int, int> dic = new Dictionary<int, int>();
|
| | | //概率为 减去上一个概率的值即为当前ID概率
|
| | | for (int i = 0;i< rateArray.Length; i++)
|
| | | for (int i = 0; i < rateArray.Length; i++)
|
| | | {
|
| | | if (i > 0)
|
| | | {
|