List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:Main.java
public static boolean removeAll(final Collection<?> c, final Object[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }//w w w . ja v a 2 s .co m return result; }
From source file:Main.java
/** * Removes all occurrences of <code>e</code> from <code>c</code>. * /* w ww . ja va2 s.c o m*/ * @param c the <code>Collection</code> * @param e the element to remove */ public static <T> void removeAll(Collection<?> c, Object e) { if (c instanceof List) { List<?> list = (List<?>) c; int index = -1; do { index = list.lastIndexOf(e); if (index != -1) list.remove(index); } while (index != -1); } else if (c instanceof Set) { c.remove(e); } else { while (c.remove(e)) ; } }
From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java
public static <T> T recurseReflect(final T obj, final DoInReflectionCallback callback) { if (obj == null) { return null; }//from ww w . j a v a2 s . co m ReflectionUtils.doWithFields(obj.getClass(), new FieldCallback() { public void doWith(Field arg0) throws IllegalArgumentException, IllegalAccessException { if (!ClassUtils.isPrimitiveOrWrapper(arg0.getType()) && !ClassUtils.isPrimitiveArray(arg0.getType()) && !ClassUtils.isPrimitiveWrapperArray(arg0.getType()) && !arg0.getType().isEnum() && (isLexBigClass(arg0.getType()) || Collection.class.isAssignableFrom(arg0.getType()) || Map.class.isAssignableFrom(arg0.getType()))) { arg0.setAccessible(true); Object recurse = arg0.get(obj); if (recurse != null) { if (CycleDetectingCallback.class.isAssignableFrom(recurse.getClass())) { System.out.println("ere"); } if (Collection.class.isAssignableFrom(recurse.getClass())) { Collection collection = (Collection) recurse; for (Object o : collection) { if (callback.actionRequired(o)) { collection.remove(o); collection.add(recurseReflect(o, callback)); } else { recurseReflect(o, callback); } } } else if (Map.class.isAssignableFrom(recurse.getClass())) { Map map = (Map) recurse; for (Object key : map.keySet()) { Object value = map.get(key); if (callback.actionRequired(key) || callback.actionRequired(value)) { map.remove(key); map.put(recurseReflect(key, callback), recurseReflect(value, callback)); } else { recurseReflect(key, callback); recurseReflect(value, callback); } } } else { if (callback.actionRequired(recurse)) { Object newObject = recurseReflect(recurse, callback); arg0.set(obj, newObject); } else { recurseReflect(recurse, callback); } } } } } }); return callback.doInReflection(obj); }
From source file:Main.java
public static boolean removeAll(final Collection<? super Byte> c, final byte[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }//from w w w .j a v a 2s .c o m return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Long> c, final long[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }/* w w w . j av a2 s. co m*/ return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Short> c, final short[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }/*from w ww .j av a 2s. c o m*/ return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Integer> c, final int[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }// w w w . j a v a 2 s . com return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Float> c, final float[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }/*from ww w . jav a2s . co m*/ return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Byte> c, final boolean[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }// w w w. java2 s. com return result; }
From source file:Main.java
public static boolean removeAll(final Collection<? super Double> c, final double[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }//www . ja v a 2s . co m return result; }