哈希表用于数据索引

哈希表用于数据索引

HashMap<String, indexstation> thishashindex = new HashMap<String, indexstation>();

// 判断有没有在列表里
								if (thishashindex.containsKey(laccell)) {
									thishashindex.get(laccell).listadd(thisindex_cell);
								} else {
									indexstation thisindexstation = new indexstation(
											Integer.parseInt(laccell.split(" ")[0]),
											Integer.parseInt(laccell.split(" ")[1]));
									thisindexstation.listadd(thisindex_cell);
									thishashindex.put(laccell, thisindexstation);
								}



// 采用Entry遍历HashMap 并输出
Set<Entry<String, indexstation>> sets = thishashindex.entrySet();
						for (Entry<String, indexstation> entry : sets) {
							String textvalue="";
							// 这里可能会出现重复问题
							int count=1;
							for (int valueint = 0; valueint < entry.getValue().getlist().size(); valueint++) {
								textvalue+=(Long.parseLong(entry.getValue().getlist().get(valueint).getid())) + ","
										+ entry.getValue().getlist().get(valueint).getlinenum() + ";";
								if(textvalue.length()>1000){
									pst.setInt(1,time);
									pst.setInt(2,Integer.parseInt(entry.getKey().split(" ")[0]));
									pst.setInt(3,Integer.parseInt(entry.getKey().split(" ")[1]));
									pst.setInt(4,count);
									pst.setString(5,textvalue);
									pst.addBatch();
									
									textvalue="";
									count++;
								}
							}
							pst.setInt(1,time);
							pst.setInt(2,Integer.parseInt(entry.getKey().split(" ")[0]));
							pst.setInt(3,Integer.parseInt(entry.getKey().split(" ")[1]));
							pst.setInt(4,count);
							pst.setString(5,textvalue);
							count++;
						}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值