迭代器将map或者list分批量操作
来源:互联网 发布:流浪诗人知乎 编辑:程序博客网 时间:2024/06/03 12:40
public static void main(String [] args){
ten();
}
//map分批量操作,长度为10
public static void ten(){Map<String,String> mapTen=new HashMap<String,String>();
mapTen.put("1", "1t");
mapTen.put("2", "2t");
mapTen.put("3", "3t");
mapTen.put("4", "4t");
mapTen.put("5", "5t");
mapTen.put("6", "6t");
mapTen.put("7", "7t");
mapTen.put("8", "8t");
mapTen.put("9", "9t");
mapTen.put("10", "10t");
mapTen.put("11", "11t");
mapTen.put("12", "12t");
mapTen.put("13", "13t");
mapTen.put("14", "14t");
mapTen.put("15", "15t");
mapTen.put("16", "16t");
if(mapTen.size() > 10){
int a=mapTen.size();
int size = (a%10==0?a/10:a/10+1);
Iterator<Entry<String, String>> iterator= mapTen.entrySet().iterator();
for(int i=0;i<size;i++){
Map<String,String> map=new HashMap<String,String>();
int j=1;
while(iterator.hasNext()){
if(j>10){
break;
}
Entry<String, String> entry=iterator.next();
map.put(entry.getKey(),entry.getValue());
j++;
}
// 操作
System.out.println(map);
}
}
}
//list迭代器分批
if(list==null||list.size()<1){
return;
}
if(list.size() > 10){
int a=list.size();
int size = (a%10==0?a/10:a/10+1);
Iterator<MessageVo> iterator= list.iterator();
for(int i=0;i<size;i++){
Map<String,String> map=new HashMap<String,String>();
List<MessageVo> list2=new ArrayList<MessageVo>();
int j=1;
while(iterator.hasNext()){
if(j>10){
break;
}
MessageVo entry=iterator.next();
list2.add(entry);
j++;
}
map.put(MsgConstantUtil.MSG_SERVER_IMUDPSERVICE_MSGMAPVO , JSON.toJSONString(list2));
// 推送消息
HttpClientUtil.post(MsgConstantUtil.MSG_SERVER_URL + MsgConstantUtil.MSG_SERVER_SENDMSG, null,map );
}
}else{
// 推送消息
HttpClientUtil.post(MsgConstantUtil.MSG_SERVER_URL + MsgConstantUtil.MSG_SERVER_SENDMSG, null, map1);
}
- 迭代器将map或者list分批量操作
- java 分批读取嵌套map的list
- 用map对一个或者多个list元素操作
- 分批操作
- Mybatis中传入值,只传入list集合或者数组或者map操作
- Java中常量Map、常量List
- Tensorflow分批量读取数据
- Tensorflow分批量读取tfrecords
- java 分批读取list
- java分批处理list
- java list分批
- JAVA LIST分批处理
- 分批次处理List
- List、Map、Set基本操作
- List、Map、Set基本操作
- velocity map list 数组操作
- JSon、Map、List转换操作
- sqldatareader 分批,分页操作数据库
- css3之box-shadow
- ffmpeg源码分析--2.av_register_all
- Java操作xml文件
- WebView实现的大致步骤
- Java开发中的23种设计模式之行为型模式(一)
- 迭代器将map或者list分批量操作
- ffmpeg源码分析--3.avformat_alloc_context与avformat_open_input
- 花花世界,不必当真
- 关于拦截器
- 千万级规模高性能、高并发的网络架构经验分享
- Supervisor安装与配置(Linux/Unix进程管理工具)
- slab内存分配
- ffmpeg源码分析--4.关于mpeg文件格式1总
- Node.js第一个代码