@Test public void memo(){ Tuple2<Integer,String> lazy = Tuple.lazy(()->10,()->{ called++; return "lazy"; }); lazy._2(); lazy._2(); assertThat(called,equalTo(2)); called= 0; Tuple2<Integer,String> memo = lazy.memo(); memo._2(); memo._2(); assertThat(called,equalTo(1)); }
public Tuple2<T1,T2> memo(){ Tuple2<T1,T2> host = this; return new Tuple2<T1,T2>(null,null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } }; }
Tuple2 implements To<Tuple2<T1,T2>>,
                                        Serializable,
                                        EqualTo<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        OrderedBy<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        Comparable<Tuple2<T1,T2>>,
                                        Higher2<tuple2,T1,T2> { public Tuple2<T1,T2> memo(){ Tuple2<T1,T2> host = this; return new Tuple2<T1,T2>(null,null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } }; } }
Tuple2 implements To<Tuple2<T1,T2>>,
                                        Serializable,
                                        EqualTo<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        OrderedBy<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        Comparable<Tuple2<T1,T2>>,
                                        Higher2<tuple2,T1,T2> { public Tuple2<T1,T2> memo(){ Tuple2<T1,T2> host = this; return new Tuple2<T1,T2>(null,null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } }; }  }
Tuple2 implements To<Tuple2<T1,T2>>,
                                        Serializable,
                                        EqualTo<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        OrderedBy<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        Comparable<Tuple2<T1,T2>>,
                                        Higher2<tuple2,T1,T2> { public Tuple2<T1,T2> memo(){ Tuple2<T1,T2> host = this; return new Tuple2<T1,T2>(null,null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } }; }  static Tuple2<T1,T2> of(T1 value1, T2 value2); static Tuple2<T1,T2> lazy(Supplier<? extends T1> supplier1,Supplier<? extends T2> supplier2); T1 _1(); T2 _2(); Tuple1<T1> first(); Tuple1<T2> second(); Tuple2<T1,T2> eager(); Tuple2<T1,T2> memo(); Tuple2<T1,R> flatMap(Monoid<T1> m,Function<? super T2, ? extends Tuple2<T1,R>> fn); R1 transform(BiFunction<? super T1, ? super T2, ? extends R1> fn1); Tuple2<R1,R2> bimap(Function<? super T1, ? extends R1> fn1,Function<? super T2,? extends R2> fn2); Tuple2<R1,R2> lazyBimap(Function<? super T1, ? extends R1> fn1,Function<? super T2,? extends R2> fn2); Tuple2<R, T2> map1(Function<? super T1, ? extends R> fn); Tuple2<R, T2> lazyMap1(Function<? super T1, ? extends R> fn); Tuple2<T1, R> map2(Function<? super T2, ? extends R> fn); Tuple2<T1, R> lazyMap2(Function<? super T2, ? extends R> fn); Tuple2<T2,T1> swap(); Tuple2<T2,T1> lazySwap(); R fold(BiFunction<? super T1, ? super T2, ? extends R> fn); @Override String toString(); static Tuple2<T1,T2> narrowK2(Higher2<tuple2,T1,T2> ds); static Tuple2<T1,T2> narrowK(Higher<Higher<tuple2, T1>, T2> ds); static Tuple2<T1,R> tailRec(Monoid<T1> op,T2 initial, Function<? super T2, ? extends Tuple2<T1,? extends Either<T2, R>>> fn); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Tuple2<T1, T2> o); final Object[] toArray(); static Tuple2< K, V> narrow(Tuple2<? extends K, ? extends V> t); static Higher2<tuple2,T1, T2> widen(Tuple2<T1,T2> narrow); Tuple3<T1, T2,T3> concat(Tuple1<T3> tuple); Tuple4<T1, T2, T3, T4> concat(Tuple2<T3,T4> tuple); Tuple5<T1, T2, T3, T4, T5> concat(Tuple3<T3, T4, T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> concat(Tuple4<T3, T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> concat(Tuple5<T3, T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> concat(Tuple6<T3, T4, T5, T6, T7, T8> tuple); Tuple3<T1, T2,T3> lazyConcat(Tuple1<T3> tuple); Tuple4<T1, T2, T3, T4> lazyConcat(Tuple2<T3,T4> tuple); Tuple5<T1, T2, T3, T4, T5> lazyConcat(Tuple3<T3, T4, T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> lazyConcat(Tuple4<T3, T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> lazyConcat(Tuple5<T3, T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> lazyConcat(Tuple6<T3, T4, T5, T6, T7, T8> tuple); }
Tuple2 implements To<Tuple2<T1,T2>>,
                                        Serializable,
                                        EqualTo<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        OrderedBy<Higher<tuple2,T1>,T2,Tuple2<T1,T2>>,
                                        Comparable<Tuple2<T1,T2>>,
                                        Higher2<tuple2,T1,T2> { public Tuple2<T1,T2> memo(){ Tuple2<T1,T2> host = this; return new Tuple2<T1,T2>(null,null){ final Supplier<T1> memo1 = Memoize.memoizeSupplier(host::_1); final Supplier<T2> memo2 = Memoize.memoizeSupplier(host::_2); @Override public T1 _1() { return memo1.get(); } @Override public T2 _2() { return memo2.get(); } }; }  static Tuple2<T1,T2> of(T1 value1, T2 value2); static Tuple2<T1,T2> lazy(Supplier<? extends T1> supplier1,Supplier<? extends T2> supplier2); T1 _1(); T2 _2(); Tuple1<T1> first(); Tuple1<T2> second(); Tuple2<T1,T2> eager(); Tuple2<T1,T2> memo(); Tuple2<T1,R> flatMap(Monoid<T1> m,Function<? super T2, ? extends Tuple2<T1,R>> fn); R1 transform(BiFunction<? super T1, ? super T2, ? extends R1> fn1); Tuple2<R1,R2> bimap(Function<? super T1, ? extends R1> fn1,Function<? super T2,? extends R2> fn2); Tuple2<R1,R2> lazyBimap(Function<? super T1, ? extends R1> fn1,Function<? super T2,? extends R2> fn2); Tuple2<R, T2> map1(Function<? super T1, ? extends R> fn); Tuple2<R, T2> lazyMap1(Function<? super T1, ? extends R> fn); Tuple2<T1, R> map2(Function<? super T2, ? extends R> fn); Tuple2<T1, R> lazyMap2(Function<? super T2, ? extends R> fn); Tuple2<T2,T1> swap(); Tuple2<T2,T1> lazySwap(); R fold(BiFunction<? super T1, ? super T2, ? extends R> fn); @Override String toString(); static Tuple2<T1,T2> narrowK2(Higher2<tuple2,T1,T2> ds); static Tuple2<T1,T2> narrowK(Higher<Higher<tuple2, T1>, T2> ds); static Tuple2<T1,R> tailRec(Monoid<T1> op,T2 initial, Function<? super T2, ? extends Tuple2<T1,? extends Either<T2, R>>> fn); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Tuple2<T1, T2> o); final Object[] toArray(); static Tuple2< K, V> narrow(Tuple2<? extends K, ? extends V> t); static Higher2<tuple2,T1, T2> widen(Tuple2<T1,T2> narrow); Tuple3<T1, T2,T3> concat(Tuple1<T3> tuple); Tuple4<T1, T2, T3, T4> concat(Tuple2<T3,T4> tuple); Tuple5<T1, T2, T3, T4, T5> concat(Tuple3<T3, T4, T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> concat(Tuple4<T3, T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> concat(Tuple5<T3, T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> concat(Tuple6<T3, T4, T5, T6, T7, T8> tuple); Tuple3<T1, T2,T3> lazyConcat(Tuple1<T3> tuple); Tuple4<T1, T2, T3, T4> lazyConcat(Tuple2<T3,T4> tuple); Tuple5<T1, T2, T3, T4, T5> lazyConcat(Tuple3<T3, T4, T5> tuple); Tuple6<T1, T2, T3, T4, T5, T6> lazyConcat(Tuple4<T3, T4, T5, T6> tuple); Tuple7<T1, T2, T3, T4, T5, T6, T7> lazyConcat(Tuple5<T3, T4, T5, T6, T7> tuple); Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> lazyConcat(Tuple6<T3, T4, T5, T6, T7, T8> tuple);  }