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

functionalj.list.intlist.IntFuncListWithMapGroup Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
// ============================================================================
// Copyright (c) 2017-2021 Nawapunth Manusitthipol (NawaMan - http://nawaman.net).
// ----------------------------------------------------------------------------
// MIT License
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ============================================================================
package functionalj.list.intlist;

import static functionalj.list.intlist.IntFuncList.deriveToDouble;
import static functionalj.list.intlist.IntFuncList.deriveToInt;
import static functionalj.list.intlist.IntFuncList.deriveToLong;
import static functionalj.list.intlist.IntFuncList.deriveToObj;

import java.util.function.IntBinaryOperator;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

import functionalj.function.Func1;
import functionalj.function.IntIntBiFunction;
import functionalj.function.IntIntToDoubleFunctionPrimitive;
import functionalj.function.IntIntToLongFunctionPrimitive;
import functionalj.list.FuncList;
import functionalj.list.doublelist.DoubleFuncList;
import functionalj.list.longlist.LongFuncList;
import functionalj.stream.intstream.IntStreamPlus;
import functionalj.tuple.IntIntTuple;

public interface IntFuncListWithMapGroup extends AsIntFuncList {
    
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default IntFuncList mapTwo(IntBinaryOperator combinator) {
        return deriveToInt(this, stream -> stream.mapTwo(combinator));
    }
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default IntFuncList mapGroup(int count, ToIntFunction combinator) {
        return deriveToInt(this, stream -> stream.mapGroup(count, combinator));
    }
    
    // == Object ==
    
    /** @return  the stream of  each previous value and each current value. */
    public default FuncList mapTwoToObj() {
        return deriveToObj(this, stream -> stream.mapTwoToObj());
    }
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default  FuncList mapTwoToObj(IntIntBiFunction combinator) {
        return deriveToObj(this, stream -> stream.mapTwoToObj(combinator));
    }
    
    /** @return  the stream of  each previous value and each current value. */
    public default FuncList mapGroupToObj(int count) {
        return deriveToObj(this, stream -> stream.mapGroupToObj(count));
    }
    
    /** @return  the stream of  each previous value and each current value. */
    public default  FuncList mapGroupToObj(int count, Func1 combinator) {
        return mapGroupToObj(count)
                .map(combinator);
    }
    
    //== Int ==
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default IntFuncList mapTwoToInt(IntBinaryOperator combinator) {
        return deriveToInt(this, stream -> stream.mapTwoToInt(combinator));
    }
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default IntFuncList mapGroupToInt(int count, ToIntFunction combinator) {
        return deriveToInt(this, stream -> stream.mapGroupToInt(count, combinator));
    }
    
    //== Long ==
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default LongFuncList mapTwoToLong(IntIntToLongFunctionPrimitive combinator) {
        return deriveToLong(this, stream -> stream.mapTwoToLong(combinator));
    }
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default LongFuncList mapGroupToLong(int count, ToLongFunction combinator) {
        return deriveToLong(this, stream -> stream.mapGroupToLong(count, combinator));
    }
    
    //== Double ==
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default DoubleFuncList mapTwoToDouble(IntIntToDoubleFunctionPrimitive combinator) {
        return deriveToDouble(this, stream -> stream.mapTwoToDouble(combinator));
    }
    
    /** Create a stream whose value is the combination between the previous value and the current value of this stream. */
    public default DoubleFuncList mapGroupToDouble(int count, ToDoubleFunction combinator) {
        return deriveToDouble(this, stream -> stream.mapGroupToDouble(count, combinator));
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy