Map - , Map . , Map , , , ( , Map.Entry). Map.Entry :
LongStream.range(1, maximum)
.mapToObj(i->new AbstractMap.SimpleEntry<>(i, Iterators.longStream(new CollatzGenerator(i)).count()))
.max(Comparator.comparingLong(Map.Entry::getValue))
.get().getKey();
, , Map.Entry, :
static final class TwoLongs {
final long key, value;
TwoLongs(long k, long v) { key=k; value=v; }
public long getKey() { return key; }
public long getValue() { return value; }
}
long s:
LongStream.range(1, maximum)
.mapToObj(i->new TwoLongs(i, Iterators.longStream(new CollatzGenerator(i)).count()))
.max(Comparator.comparingLong(TwoLongs::getValue))
.get().getKey();
, - , ( TwoLongs) ( Map.Entry long s).