/** * Return a copy of this array with only the * given index(es) remaining * * @param data the data to copy * @param index the index of the item to remove * @return the new array with the omitted * item */ public static long[] keep(long[] data, int... index) { if (index.length == data.length) return data; long[] ret = new long[index.length]; int count = 0; for (int i = 0; i < data.length; i++) if (Ints.contains(index, i)) ret[count++] = data[i]; return ret; }
/** * Return a copy of this array with only the * given index(es) remaining * * @param data the data to copy * @param index the index of the item to remove * @return the new array with the omitted * item */ public static int[] keep(int[] data, int... index) { if (index.length == data.length) return data; int[] ret = new int[index.length]; int count = 0; for (int i = 0; i < data.length; i++) if (Ints.contains(index, i)) ret[count++] = data[i]; return ret; }
public static long[] removeIndex(long[] data, int... index) { if (index.length >= data.length) { throw new IllegalStateException("Illegal remove: indexes.length > data.length (index.length=" + index.length + ", data.length=" + data.length + ")"); } int offset = 0; /* workaround for non-existent indexes (such as Integer.MAX_VALUE) for (int i = 0; i < index.length; i ++) { if (index[i] >= data.length || index[i] < 0) offset++; } */ long[] ret = new long[data.length - index.length + offset]; int count = 0; for (int i = 0; i < data.length; i++) if (!Ints.contains(index, i)) { ret[count++] = data[i]; } return ret; }
int count = 0; for (int i = 0; i < data.length; i++) if (!Ints.contains(index, i)) { ret[count++] = data[i];
public void testContains() { assertFalse(Ints.contains(EMPTY, (int) 1)); assertFalse(Ints.contains(ARRAY1, (int) 2)); assertFalse(Ints.contains(ARRAY234, (int) 1)); assertTrue(Ints.contains(new int[] {(int) -1}, (int) -1)); assertTrue(Ints.contains(ARRAY234, (int) 2)); assertTrue(Ints.contains(ARRAY234, (int) 3)); assertTrue(Ints.contains(ARRAY234, (int) 4)); }
@Override protected boolean isSelected(String value) { int[] val = value(); return val != null && Ints.contains(val, frameColumnNameToIndex(fr(), value, _namesOnly)); }
/** Could any trip on this trip pattern possibly match this filter? */ protected boolean couldMatch (TripPattern pattern) { if (!pattern.route.getAgency().getId().equals(agencyId)) return false; if (routeId != null && !routeId.contains(pattern.route.getId().getId())) return false; if (routeType != null && !Ints.contains(routeType, pattern.route.getType())) return false; return true; }
/** Does this TripTimes match the match parameters defined here? */ protected boolean matches(Trip trip) { Route route = trip.getRoute(); if (!route.getAgency().getId().equals(agencyId)) return false; if (routeId != null && !routeId.contains(route.getId().getId())) return false; if (tripId != null && !tripId.contains(trip.getId().getId())) return false; if (routeType != null && !Ints.contains(routeType, trip.getRoute().getType())) return false; return true; } }
/** * Checks if this array contains the specified value. * * @param value the value to find * @return true if the value is contained in this array */ public boolean contains(int value) { return Ints.contains(array, value); }
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; for (int i = combination.length-2; i >= 0; i--) { factor[i] = factor[i+1]* numChunk[i+1]; } }
public static boolean canCreateTypedField(Type<?> type) { return Ints.contains(TYPABLE_TAGS, type.tag()); }
public static boolean canCreateTypedField(Type<?> type) { return Ints.contains(TYPABLE_TAGS, type.tag()); }
/** * {@inheritDoc} * * @throws NullPointerException * if the wrapped array was <code>null</code>. */ @Override public boolean contains(Object o) { // Will make the method fail if array is null. if (size() < 1) { return false; } if (o instanceof Integer) { return Ints.contains(array, ((Integer) o).intValue()); } return false; }
public void testContains() { assertFalse(Ints.contains(EMPTY, (int) 1)); assertFalse(Ints.contains(ARRAY1, (int) 2)); assertFalse(Ints.contains(ARRAY234, (int) 1)); assertTrue(Ints.contains(new int[] {(int) -1}, (int) -1)); assertTrue(Ints.contains(ARRAY234, (int) 2)); assertTrue(Ints.contains(ARRAY234, (int) 3)); assertTrue(Ints.contains(ARRAY234, (int) 4)); }
@Test public void testMounFlavors() throws IOException { String path = "/some/export"; mountres3 res = mountServer() .withPath(path) .exportedTo("192.168.178.33") .withSecurity(FsExport.Sec.KRB5). accessedFrom("192.168.178.33"). toMount(path); assertEquals(mountstat3.MNT3_OK, res.fhs_status); assertTrue(contains(res.mountinfo.auth_flavors, MountServer.RPC_AUTH_GSS_KRB5I)); assertTrue(contains(res.mountinfo.auth_flavors, MountServer.RPC_AUTH_GSS_KRB5P)); assertFalse(contains(res.mountinfo.auth_flavors, MountServer.RPC_AUTH_GSS_KRB5)); assertFalse(contains(res.mountinfo.auth_flavors, RpcAuthType.NONE)); assertFalse(contains(res.mountinfo.auth_flavors, RpcAuthType.UNIX)); }