Provide an iterator over the contents of two lists simultaneously?

前端 未结 11 2075
逝去的感伤
逝去的感伤 2020-12-03 04:45

Suppose I have this:

public class Unit {

    ...

    List mobileSuits;
    List pilots;

    ...
}
         


        
11条回答
  •  一个人的身影
    2020-12-03 05:29

    You could just use a Map, where a null value mapped to a MobileSuit indicates no pilot. The Iterator could just be an Iterator> retrieved by map.entrySet().iterator().

提交回复
热议问题