All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aol.cyclops.lambda.tuple.lazymap.LazyMap3PTuple8 Maven / Gradle / Ivy

There is a newer version: 7.2.4
Show newest version
package com.aol.cyclops.lambda.tuple.lazymap;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;

import com.aol.cyclops.closures.immutable.LazyImmutable;
import com.aol.cyclops.lambda.tuple.PTuple8;
import com.aol.cyclops.lambda.tuple.TupleImpl;

public class LazyMap3PTuple8 extends TupleImpl {
	 private final LazyImmutable value = LazyImmutable.def();
	 private final Function fn;
	 private final PTuple8 host;
	public LazyMap3PTuple8( Function fn,PTuple8 host){
		super(host.arity());
		this.host = host;
		this.fn = fn;
	}
		public T v3(){
			return value.computeIfAbsent(()->fn.apply(host.v3())); 
		}

		@Override
		public List getCachedValues() {
			return Arrays.asList(v1(),v2());
		}

		@Override
		public Iterator iterator() {
			return getCachedValues().iterator();
		}

		
	};