List of utility methods to do Collection First
T | nullSafeFirstElement(Collection null Safe First Element try { return collection.iterator().next(); } catch (Exception e) { return null; |
List | removeFirst(Collection collection, int numToRemove) Removes and returns the first n items from the given collection. int toRemove = Math.min(collection.size(), numToRemove); List removed = new ArrayList(toRemove); Iterator iter = collection.iterator(); for (int idx = 0; idx < toRemove; idx++) { removed.add(iter.next()); iter.remove(); return removed; ... |
Collection | removeFirst(Collection remove First List<X> list; if (c == null || c.size() == 0) { list = Collections.emptyList(); } else { list = new ArrayList<X>(c); list.remove(0); return list; ... |
Collection | sub(Collection coll, int first, int size) sub if (coll == null) { return null; if (coll.size() < size && first == 0) { return coll; } else { List sub = new ArrayList(size); int i = -1; ... |
Collection | subtract(Collection firstCollection, Collection secondCollection) subtract Collection collection = new ArrayList<>(); for (Object object : firstCollection) { if (!secondCollection.contains(object)) { collection.add(object); return collection; |
Collection | union(Collection firstSet, Collection secondSet) union return null;
|