Iterate twice on values (MapReduce)

前端 未结 11 1067
轮回少年
轮回少年 2020-11-29 07:22

I receive an iterator as argument and I would like to iterate on values twice.

public void reduce(Pair key, Iterator          


        
11条回答
  •  -上瘾入骨i
    2020-11-29 08:20

    Try this:

        ListIterator it = list.listIterator();
    
        while(it.hasNext()){
    
            while(it.hasNext()){
                System.out.println("back " + it.next() +" "); 
            }
            while(it.hasPrevious()){
                it.previous();
            }
        }
    

提交回复
热议问题