Example usage for com.google.common.primitives Ints contains

List of usage examples for com.google.common.primitives Ints contains

Introduction

In this page you can find the example usage for com.google.common.primitives Ints contains.

Prototype

public static boolean contains(int[] array, int target) 

Source Link

Document

Returns true if target is present as an element anywhere in array .

Usage

From source file:org.apache.jackrabbit.oak.plugins.index.lucene.FieldFactory.java

public static boolean canCreateTypedField(Type<?> type) {
    return Ints.contains(TYPABLE_TAGS, type.tag());
}

From source file:org.sonatype.nexus.orient.RecordIdObfuscatorSupport.java

/**
 * @see #doDecode(OClass, String)/*w  ww .  j a v a 2s  .c o  m*/
 */
@Override
public ORID decode(final OClass type, final String encoded) {
    checkNotNull(type);
    checkNotNull(encoded);

    log.trace("Decoding: {}->{}", type, encoded);
    ORID rid;
    try {
        rid = doDecode(type, encoded);
    } catch (Exception e) {
        log.error("Failed to decode: {}->{}", type, encoded);
        throw Throwables.propagate(e);
    }

    // ensure rid points to the right type
    checkArgument(Ints.contains(type.getClusterIds(), rid.getClusterId()), "Invalid RID '%s' for class: %s",
            rid, type);

    return rid;
}

From source file:org.apache.tez.runtime.library.cartesianproduct.CartesianProductCombination.java

public CartesianProductCombination(int[] numChunk) {
    Preconditions.checkArgument(!Ints.contains(numChunk, 0),
            "CartesianProductCombination doesn't allow zero chunk");
    this.numChunk = Arrays.copyOf(numChunk, numChunk.length);
    combination = new Integer[numChunk.length];
    factor = new Integer[numChunk.length];
    factor[factor.length - 1] = 1;//ww w.j ava 2  s. co m
    for (int i = combination.length - 2; i >= 0; i--) {
        factor[i] = factor[i + 1] * numChunk[i + 1];
    }
}

From source file:org.gitools.heatmap.Bookmarks.java

public Bookmark createNew(Heatmap heatmap, String bookmarkName, String description, int[] include) {
    String name = bookmarkName;//from   w  w w  .j ava  2 s  .  c om
    int counter = 1;
    while (nameOccupied(name)) {
        name = bookmarkName + "-" + counter++;
    }

    if (include == null || include.length == 0) {
        include = new int[] { ROWS, COLUMNS, LAYER };
    }

    List<String> rows = null;
    List<String> cols = null;

    if (Ints.contains(include, ROWS)) {
        rows = new ArrayList<>();
        Iterables.addAll(rows, heatmap.getRows());
    }

    if (Ints.contains(include, COLUMNS)) {
        cols = new ArrayList<>();
        Iterables.addAll(cols, heatmap.getColumns());
    }

    String layerId = Ints.contains(include, LAYER) ? heatmap.getLayers().getTopLayer().getId() : null;

    Bookmark b = new Bookmark(name, rows, cols, layerId);
    b.setDescription(description);
    add(b);
    return b;
}

From source file:dk.philiphansen.craftech.tileentity.TileEntityBlastFurnace.java

@Override
public boolean canInsertItem(int slot, ItemStack stack, int side) {
    return Ints.contains(getAccessibleSlotsFromSide(side), slot) && isItemValidForSlot(slot, stack);
}

From source file:dk.philiphansen.craftech.tileentity.TileEntityBlastFurnace.java

@Override
public boolean canExtractItem(int slot, ItemStack stack, int side) {
    return Ints.contains(getAccessibleSlotsFromSide(side), slot) && getStackInSlot(slot) == stack;
}

From source file:dk.philiphansen.craftech.tileentities.TileentityBlastFurnace.java

@Override
public boolean canInsertItem(int slot, ItemStack stack, int side) {
    if (Ints.contains(getAccessibleSlotsFromSide(side), slot) && isItemValidForSlot(slot, stack)) {
        return true;
    } else {/*  www  . j av a  2 s . co  m*/
        return false;
    }
}

From source file:dk.philiphansen.craftech.tileentities.TileentityBlastFurnace.java

@Override
public boolean canExtractItem(int slot, ItemStack stack, int side) {
    if (Ints.contains(getAccessibleSlotsFromSide(side), slot) && getStackInSlot(slot) == stack) {
        return true;
    } else {/* w ww.ja va2s.co  m*/
        return false;
    }
}

From source file:com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Views.Component.CViewsTable.java

/**
 * Returns the selected views of the table. If the view of the passed row index is already
 * selected, then the selected views are returned. Otherwise, the given row is selected and the
 * view of that row is returned./*w w w  . j  a v  a 2 s. co  m*/
 *
 * @param sortedRow Row to be selected.
 *
 * @return Selected views.
 */
private INaviView[] getSelectedViews(final int sortedRow) {
    final int[] sortSelectedRows = getSortSelectedRows();
    if (Ints.contains(sortSelectedRows, sortedRow)) {
        return getViews(sortSelectedRows);
    } else {
        final int viewRow = convertRowIndexToView(sortedRow);
        setRowSelectionInterval(viewRow, viewRow);
        return getViews(new int[] { sortedRow });
    }
}

From source file:org.nd4j.linalg.api.ops.impl.accum.TensorMmul.java

private SDVariable doTensorMmul(SDVariable a, SDVariable b, int[][] axes) {

    int validationLength = Math.min(axes[0].length, axes[1].length);
    for (int i = 0; i < validationLength; i++) {
        if (a.getShape()[axes[0][i]] != b.getShape()[axes[1][i]])
            throw new IllegalArgumentException(
                    "Size of the given axes at each dimension must be the same size.");
        if (axes[0][i] < 0)
            axes[0][i] += a.getShape().length;
        if (axes[1][i] < 0)
            axes[1][i] += b.getShape().length;

    }//from www .  j  a va 2s. c  o m

    List<Integer> listA = new ArrayList<>();
    for (int i = 0; i < a.getShape().length; i++) {
        if (!Ints.contains(axes[0], i))
            listA.add(i);
    }

    int[] newAxesA = Ints.concat(Ints.toArray(listA), axes[0]);

    List<Integer> listB = new ArrayList<>();
    for (int i = 0; i < b.getShape().length; i++) {
        if (!Ints.contains(axes[1], i))
            listB.add(i);
    }

    int[] newAxesB = Ints.concat(axes[1], Ints.toArray(listB));

    int n2 = 1;
    int aLength = Math.min(a.getShape().length, axes[0].length);
    for (int i = 0; i < aLength; i++) {
        n2 *= a.getShape()[axes[0][i]];
    }

    //if listA and listB are empty these do not initialize.
    //so initializing with {1} which will then get overridden if not empty
    long[] newShapeA = { -1, n2 };
    long[] oldShapeA;
    if (listA.size() == 0) {
        oldShapeA = new long[] { 1 };
    } else {
        oldShapeA = Longs.toArray(listA);
        for (int i = 0; i < oldShapeA.length; i++)
            oldShapeA[i] = a.getShape()[(int) oldShapeA[i]];
    }

    int n3 = 1;
    int bNax = Math.min(b.getShape().length, axes[1].length);
    for (int i = 0; i < bNax; i++) {
        n3 *= b.getShape()[axes[1][i]];
    }

    int[] newShapeB = { n3, -1 };
    long[] oldShapeB;
    if (listB.size() == 0) {
        oldShapeB = new long[] { 1 };
    } else {
        oldShapeB = Longs.toArray(listB);
        for (int i = 0; i < oldShapeB.length; i++)
            oldShapeB[i] = b.getShape()[(int) oldShapeB[i]];
    }

    SDVariable at = f().reshape(f().permute(a, newAxesA), newShapeA);
    SDVariable bt = f().reshape(f().permute(b, newAxesB), newShapeB);

    SDVariable ret = f().mmul(at, bt);
    long[] aPlusB = Longs.concat(oldShapeA, oldShapeB);
    return f().reshape(ret, aPlusB);
}