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

com.meliorbis.numerics.generic.impl.IntegerArray Maven / Gradle / Ivy

Go to download

A library for working with large multi-dimensional arrays and the functions they represent

There is a newer version: 1.2
Show newest version
package com.meliorbis.numerics.generic.impl;

import java.util.Comparator;

import com.meliorbis.numerics.generic.ArrayFactory1D;
import com.meliorbis.numerics.generic.ArrayFactory2D;
import com.meliorbis.numerics.generic.BinaryOp;
import com.meliorbis.numerics.index.SubIndex;
import com.meliorbis.numerics.threading.Executor;

/**
 * Specialisation of GenericBlockedArray for Integer objects
 *
 * @author Tobias Grasl
 */
public class IntegerArray extends GenericBlockedArray implements com.meliorbis.numerics.generic.IntegerArray
{
    public IntegerArray(Executor _executor, int[] dimensions_)
    {
        super(_executor, dimensions_);
    }

    public IntegerArray(BlockedArrayData data_, SubIndex dimensionCounter_, Executor executor_)
    {
        super(data_, dimensionCounter_, executor_);
    }

    @Override
    protected IntegerArray createSub(BlockedArrayData data_, SubIndex dimensionCounter_)
    {
        return new IntegerArray(data_, dimensionCounter_, _executor);
    }

    @Override
    protected ArrayFactory2D getArrayFactory2D()
    {
        return length -> new Integer[length][];
    }

    @Override
    protected ArrayFactory1D getArrayFactory1D()
    {
        return length -> new Integer[length];
    }

    @Override
    protected IntegerArray createNew(int... dimensions_)
    {
        return new IntegerArray(_executor, dimensions_);
    }

    @Override
    protected Integer getZero()
    {
        return 0;
    }

    @Override
    protected Integer getMinusOne()
    {
        return -1;
    }

    @Override
    public BinaryOp getAddOp()
    {
        return (a,b) -> a + b;
    }

    @Override
    public BinaryOp getSubtractionOp()
    {
        return (a,b) -> a - b;
    }

    @Override
    public BinaryOp getMultOp()
    {
        return (a,b) -> a * b;
    }

    @Override
    public BinaryOp getDivisionOp()
    {
        return (a,b) -> a / b;
    }

    @Override
    public Comparator getComparator()
    {
        return (a, b) -> a == null ? -1 : (b == null ? 1 : a.compareTo(b)) ;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy