合并两个List数据

/*
* 根据不同的彩种,抓取并返回数据
*/
public List<Match> getgrabClassMatchByLotteryAndissueNo(LotteryType lotteryType,
String issue_no, String grabClass) {
// 以下为抓取代码
MatchGrab matchGrab = this.getGrab(grabClass);
List<Match> macthList = null;
List<Match> rateList = null;
//List<Match> list = null;
// 判断不同的彩种调用不同的抓取
if (LotteryType.JJ_14SFC.equals(lotteryType)) {
macthList = matchGrab.queryMatch149(issue_no);
rateList = matchGrab.get14C_OP(issue_no);
} else if (LotteryType.JJ_6CBQC.equals(lotteryType)) {
macthList = matchGrab.queryMatch6(issue_no);
rateList = matchGrab.get6C_OP(issue_no);
} else {
macthList = matchGrab.queryMatch4(issue_no);
rateList = matchGrab.get4C_OP(issue_no);
}

ArrayList<Match> Match_list  = new ArrayList<Match>();
for (int i =0 ; i < macthList.size(); i++) {
Match match = macthList.get(i); //前半部数据
Match rate = rateList.get(i);//后半部数据
match.setLottery_type(lotteryType);
match.setIssue_no(issue_no);
match.setHalf_score(rate.getHalf_score());
match.setFinal_score(rate.getFinal_score());
match.setWin_rate(rate.getWin_rate());
match.setDeuce_rate(rate.getDeuce_rate());
match.setLose_rate(rate.getLose_rate());
match.setMatch_time(match.getMatch_time());

}



return macthList;
}
可以使用遍历法来合并两个有序链表。首先创建一个哨兵节点作为合并后链表的头部。然后,遍历两个链表,比较节点的值大小,将较小的节点连接到合并链表的后面。当其中一个链表遍历完后,直接将另一个链表的剩余部分连接到合并链表的后面。最后返回合并链表的头部即可。以下是一个示例代码: ```python class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: prehead = ListNode(-1) # 创建一个哨兵节点 pre = prehead while l1 and l2: if l1.val > l2.val: pre.next = l2 l2 = l2.next else: pre.next = l1 l1 = l1.next pre = pre.next pre.next = l1 if l1 else l2 # 将剩余部分连接到合并链表的后面 return prehead.next # 示例数据 l1 = ListNode([1,2,4]) l2 = ListNode([1,3,4]) s = Solution() l = s.mergeTwoLists(l1,l2) while l: print(l.val) l = l.next ``` 输出结果为:1 1 2 3 4 4<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [python实现合并两个有序列表](https://blog.csdn.net/sinat_29957455/article/details/113420273)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [go合并两个有序列表](https://download.csdn.net/download/weixin_38507121/14041237)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值